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

Function TestNewJSONNoEmail

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

Source from the content-addressed store, hash-verified

162}
163
164func TestNewJSONNoEmail(t *testing.T) {
165 tmpHome := t.TempDir()
166
167 fn := filepath.Join(tmpHome, ConfigFileName)
168 js := ` { "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv" } } }`
169 if err := os.WriteFile(fn, []byte(js), 0o600); err != nil {
170 t.Fatal(err)
171 }
172
173 config, err := Load(tmpHome)
174 assert.NilError(t, err)
175
176 ac := config.AuthConfigs["https://index.docker.io/v1/"]
177 assert.Equal(t, ac.Username, "joejoe")
178 assert.Equal(t, ac.Password, "hello")
179
180 // Now save it and make sure it shows up in new form
181 configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
182
183 expConfStr := `{
184 "auths": {
185 "https://index.docker.io/v1/": {
186 "auth": "am9lam9lOmhlbGxv"
187 }
188 }
189}`
190
191 if configStr != expConfStr {
192 t.Fatalf("Should have save in new form: \n%s\n not \n%s", configStr, expConfStr)
193 }
194}
195
196func TestJSONWithPsFormat(t *testing.T) {
197 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…