Fix golint failures in pkg/credentialprovider (#88860)

* Fix golint failures in pkg/credentialprovider

* improve Comment

* test
This commit is contained in:
zzde
2020-03-19 11:10:43 +08:00
committed by GitHub
parent 42972f2a37
commit a95d04993a
7 changed files with 163 additions and 150 deletions

View File

@@ -27,11 +27,11 @@ import (
)
func TestReadDockerConfigFile(t *testing.T) {
configJsonFileName := "config.json"
configJSONFileName := "config.json"
var fileInfo *os.File
//test dockerconfig json
inputDockerconfigJsonFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"
inputDockerconfigJSONFile := "{ \"auths\": { \"http://foo.example.com\":{\"auth\":\"Zm9vOmJhcgo=\",\"email\":\"foo@example.com\"}}}"
preferredPath, err := ioutil.TempDir("", "test_foo_bar_dockerconfigjson_")
if err != nil {
@@ -39,7 +39,7 @@ func TestReadDockerConfigFile(t *testing.T) {
return
}
defer os.RemoveAll(preferredPath)
absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(preferredPath, configJsonFileName))
absDockerConfigFileLocation, err := filepath.Abs(filepath.Join(preferredPath, configJSONFileName))
if err != nil {
t.Fatalf("While trying to canonicalize %s: %v", preferredPath, err)
}
@@ -53,7 +53,7 @@ func TestReadDockerConfigFile(t *testing.T) {
defer fileInfo.Close()
}
fileInfo.WriteString(inputDockerconfigJsonFile)
fileInfo.WriteString(inputDockerconfigJSONFile)
orgPreferredPath := GetPreferredDockercfgPath()
SetPreferredDockercfgPath(preferredPath)
@@ -66,7 +66,7 @@ func TestDockerConfigJsonJSONDecode(t *testing.T) {
// Fake values for testing.
input := []byte(`{"auths": {"http://foo.example.com":{"username": "foo", "password": "bar", "email": "foo@example.com"}, "http://bar.example.com":{"username": "bar", "password": "baz", "email": "bar@example.com"}}}`)
expect := DockerConfigJson{
expect := DockerConfigJSON{
Auths: DockerConfig(map[string]DockerConfigEntry{
"http://foo.example.com": {
Username: "foo",
@@ -81,7 +81,7 @@ func TestDockerConfigJsonJSONDecode(t *testing.T) {
}),
}
var output DockerConfigJson
var output DockerConfigJSON
err := json.Unmarshal(input, &output)
if err != nil {
t.Errorf("Received unexpected error: %v", err)