(t *testing.T)
| 331 | } |
| 332 | |
| 333 | func TestJSONSaveWithNoFile(t *testing.T) { |
| 334 | js := `{ |
| 335 | "auths": { "https://index.docker.io/v1/": { "auth": "am9lam9lOmhlbGxv" } }, |
| 336 | "psFormat": "table {{.ID}}\\t{{.Label \"com.docker.label.cpu\"}}" |
| 337 | }` |
| 338 | config, err := LoadFromReader(strings.NewReader(js)) |
| 339 | assert.NilError(t, err) |
| 340 | err = config.Save() |
| 341 | assert.ErrorContains(t, err, "with empty filename") |
| 342 | |
| 343 | tmpHome := t.TempDir() |
| 344 | |
| 345 | fn := filepath.Join(tmpHome, ConfigFileName) |
| 346 | f, _ := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) |
| 347 | defer f.Close() |
| 348 | |
| 349 | assert.NilError(t, config.SaveToWriter(f)) |
| 350 | buf, err := os.ReadFile(filepath.Join(tmpHome, ConfigFileName)) |
| 351 | assert.NilError(t, err) |
| 352 | expConfStr := `{ |
| 353 | "auths": { |
| 354 | "https://index.docker.io/v1/": { |
| 355 | "auth": "am9lam9lOmhlbGxv" |
| 356 | } |
| 357 | }, |
| 358 | "psFormat": "table {{.ID}}\\t{{.Label \"com.docker.label.cpu\"}}" |
| 359 | }` |
| 360 | if string(buf) != expConfStr { |
| 361 | t.Fatalf("Should have save in new form: \n%s\nnot \n%s", string(buf), expConfStr) |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | func TestLoadDefaultConfigFile(t *testing.T) { |
| 366 | dir := setupConfigDir(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…