(t *testing.T)
| 183 | } |
| 184 | |
| 185 | func TestDuplicateFiles(t *testing.T) { |
| 186 | co := newCapturedOutput() |
| 187 | co.override() |
| 188 | defer co.reset() |
| 189 | |
| 190 | // The fake endpoint will populate this when it receives the call from the command. |
| 191 | submittedFiles := map[string]string{} |
| 192 | ts := fakeSubmitServer(t, submittedFiles) |
| 193 | defer ts.Close() |
| 194 | |
| 195 | tmpDir, err := os.MkdirTemp("", "duplicate-files") |
| 196 | defer os.RemoveAll(tmpDir) |
| 197 | assert.NoError(t, err) |
| 198 | |
| 199 | dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise") |
| 200 | os.MkdirAll(dir, os.FileMode(0755)) |
| 201 | |
| 202 | writeFakeMetadata(t, dir, "bogus-track", "bogus-exercise") |
| 203 | |
| 204 | v := viper.New() |
| 205 | v.Set("token", "abc123") |
| 206 | v.Set("workspace", tmpDir) |
| 207 | v.Set("apibaseurl", ts.URL) |
| 208 | |
| 209 | cfg := config.Config{ |
| 210 | Persister: config.InMemoryPersister{}, |
| 211 | UserViperConfig: v, |
| 212 | } |
| 213 | |
| 214 | file1 := filepath.Join(dir, "file-1.txt") |
| 215 | err = os.WriteFile(file1, []byte("This is file 1."), os.FileMode(0755)) |
| 216 | |
| 217 | err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{file1, file1}) |
| 218 | assert.NoError(t, err) |
| 219 | |
| 220 | assert.Equal(t, 1, len(submittedFiles)) |
| 221 | assert.Equal(t, "This is file 1.", submittedFiles["file-1.txt"]) |
| 222 | } |
| 223 | |
| 224 | func TestSubmitFiles(t *testing.T) { |
| 225 | co := newCapturedOutput() |
nothing calls this directly
no test coverage detected