(t *testing.T)
| 130 | } |
| 131 | |
| 132 | func 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 | |
| 164 | func TestNewJSONNoEmail(t *testing.T) { |
| 165 | tmpHome := t.TempDir() |
nothing calls this directly
no test coverage detected
searching dependent graphs…