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

Function TestJSONWithPsFormat

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

Source from the content-addressed store, hash-verified

194}
195
196func TestJSONWithPsFormat(t *testing.T) {
197 tmpHome := t.TempDir()
198
199 fn := filepath.Join(tmpHome, ConfigFileName)
200 js := `{
201 "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv", "email": "user@example.com" } },
202 "psFormat": "table {{.ID}}\\t{{.Label \"com.docker.label.cpu\"}}"
203}`
204 if err := os.WriteFile(fn, []byte(js), 0o600); err != nil {
205 t.Fatal(err)
206 }
207
208 config, err := Load(tmpHome)
209 assert.NilError(t, err)
210
211 if config.PsFormat != `table {{.ID}}\t{{.Label "com.docker.label.cpu"}}` {
212 t.Fatalf("Unknown ps format: %s\n", config.PsFormat)
213 }
214
215 // Now save it and make sure it shows up in new form
216 configStr := saveConfigAndValidateNewFormat(t, config, tmpHome)
217 if !strings.Contains(configStr, `"psFormat":`) ||
218 !strings.Contains(configStr, "{{.ID}}") {
219 t.Fatalf("Should have save in new form: %s", configStr)
220 }
221}
222
223func TestJSONWithCredentialStore(t *testing.T) {
224 tmpHome := t.TempDir()

Callers

nothing calls this directly

Calls 3

ContainsMethod · 0.80
LoadFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…