You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
737 B
Go
29 lines
737 B
Go
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform License
|
|
// that can be found in the LICENSE file.
|
|
|
|
package auths
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.awesome-for.me/liuzhiguo/drone-go/drone"
|
|
)
|
|
|
|
func TestEncode(t *testing.T) {
|
|
endpoint := "docker.io"
|
|
username := "octocat"
|
|
password := "correct-horse-battery-staple"
|
|
registry := &drone.Registry{
|
|
Username: username,
|
|
Password: password,
|
|
Address: endpoint,
|
|
}
|
|
got := Encode(registry, registry, registry)
|
|
want := `{"auths":{"docker.io":{"auth":"b2N0b2NhdDpjb3JyZWN0LWhvcnNlLWJhdHRlcnktc3RhcGxl"}}}`
|
|
if strings.TrimSpace(got) != strings.TrimSpace(want) {
|
|
t.Errorf("Unexpected encoding: %q want %q", got, want)
|
|
}
|
|
}
|