(t *testing.T)
| 652 | } |
| 653 | |
| 654 | func TestSubmissionNotConnectedToRequesterAccount(t *testing.T) { |
| 655 | submittedFiles := map[string]string{} |
| 656 | ts := fakeSubmitServer(t, submittedFiles) |
| 657 | defer ts.Close() |
| 658 | |
| 659 | tmpDir, err := os.MkdirTemp("", "submit-files") |
| 660 | defer os.RemoveAll(tmpDir) |
| 661 | assert.NoError(t, err) |
| 662 | |
| 663 | dir := filepath.Join(tmpDir, "bogus-track", "bogus-exercise") |
| 664 | os.MkdirAll(filepath.Join(dir, "subdir"), os.FileMode(0755)) |
| 665 | |
| 666 | metadata := &workspace.ExerciseMetadata{ |
| 667 | ID: "bogus-solution-uuid", |
| 668 | Track: "bogus-track", |
| 669 | ExerciseSlug: "bogus-exercise", |
| 670 | URL: "http://example.com/bogus-url", |
| 671 | IsRequester: false, |
| 672 | } |
| 673 | err = metadata.Write(dir) |
| 674 | assert.NoError(t, err) |
| 675 | |
| 676 | file1 := filepath.Join(dir, "file-1.txt") |
| 677 | err = os.WriteFile(file1, []byte("This is file 1."), os.FileMode(0755)) |
| 678 | assert.NoError(t, err) |
| 679 | |
| 680 | v := viper.New() |
| 681 | v.Set("token", "abc123") |
| 682 | v.Set("workspace", tmpDir) |
| 683 | v.Set("apibaseurl", ts.URL) |
| 684 | |
| 685 | cfg := config.Config{ |
| 686 | Persister: config.InMemoryPersister{}, |
| 687 | Dir: tmpDir, |
| 688 | UserViperConfig: v, |
| 689 | } |
| 690 | |
| 691 | err = runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{file1}) |
| 692 | if assert.Error(t, err) { |
| 693 | assert.Regexp(t, "not connected to your account", err.Error()) |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | func TestExerciseDirnameMatchesMetadataSlug(t *testing.T) { |
| 698 | submittedFiles := map[string]string{} |
nothing calls this directly
no test coverage detected