MCPcopy Create free account
hub / github.com/docker/cli / TestNewJSON

Function TestNewJSON

cli/config/config_test.go:132–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

130}
131
132func TestNewJSON(t *testing.T) {
133 tmpHome := t.TempDir()
134
135 fn := filepath.Join(tmpHome, ConfigFileName)
136 js := ` { "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv" } } }`
137 if err := os.WriteFile(fn, []byte(js), 0o600); err != nil {
138 t.Fatal(err)
139 }
140
141 config, err := Load(tmpHome)
142 assert.NilError(t, err)
143
144 ac := config.AuthConfigs["https://index.docker.io/v1/"]
145 assert.Equal(t, ac.Username, "joejoe")
146 assert.Equal(t, ac.Password, "hello")
147
148 // Now save it and make sure it shows up in new form
149 configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
150
151 expConfStr := `{
152 "auths": {
153 "https://index.docker.io/v1/": {
154 "auth": "am9lam9lOmhlbGxv"
155 }
156 }
157}`
158
159 if configStr != expConfStr {
160 t.Fatalf("Should have save in new form: \n%s\n not \n%s", configStr, expConfStr)
161 }
162}
163
164func TestNewJSONNoEmail(t *testing.T) {
165 tmpHome := t.TempDir()

Callers

nothing calls this directly

Calls 2

LoadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…