(t *testing.T)
| 384 | } |
| 385 | |
| 386 | func TestSubmitWithEnormousFile(t *testing.T) { |
| 387 | co := newCapturedOutput() |
| 388 | co.override() |
| 389 | defer co.reset() |
| 390 | |
| 391 | // The fake endpoint will populate this when it receives the call from the command. |
| 392 | submittedFiles := map[string]string{} |
| 393 | ts := fakeSubmitServer(t, submittedFiles) |
| 394 | defer ts.Close() |
| 395 | |
| 396 | tmpDir, err := os.MkdirTemp("", "enormous-file") |
| 397 | defer os.RemoveAll(tmpDir) |
| 398 | assert.NoError(t, err) |
| 399 | |
| 400 | dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise") |
| 401 | os.MkdirAll(dir, os.FileMode(0755)) |
| 402 | |
| 403 | writeFakeMetadata(t, dir, "bogus-track", "bogus-exercise") |
| 404 | |
| 405 | v := viper.New() |
| 406 | v.Set("token", "abc123") |
| 407 | v.Set("workspace", tmpDir) |
| 408 | v.Set("apibaseurl", ts.URL) |
| 409 | |
| 410 | cfg := config.Config{ |
| 411 | Persister: config.InMemoryPersister{}, |
| 412 | UserViperConfig: v, |
| 413 | } |
| 414 | |
| 415 | file := filepath.Join(dir, "file.txt") |
| 416 | err = os.WriteFile(file, make([]byte, 65535), os.FileMode(0755)) |
| 417 | if err != nil { |
| 418 | t.Fatal(err) |
| 419 | } |
| 420 | |
| 421 | err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{file}) |
| 422 | |
| 423 | if assert.Error(t, err) { |
| 424 | assert.Regexp(t, "Please reduce the size of the file and try again.", err.Error()) |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | func TestSubmitOnlyEmptyFile(t *testing.T) { |
| 429 | co := newCapturedOutput() |
nothing calls this directly
no test coverage detected