(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestWorkspacePotentialExercises(t *testing.T) { |
| 14 | tmpDir, err := os.MkdirTemp("", "walk") |
| 15 | defer os.RemoveAll(tmpDir) |
| 16 | assert.NoError(t, err) |
| 17 | |
| 18 | a1 := filepath.Join(tmpDir, "track-a", "exercise-one") |
| 19 | b1 := filepath.Join(tmpDir, "track-b", "exercise-one") |
| 20 | b2 := filepath.Join(tmpDir, "track-b", "exercise-two") |
| 21 | |
| 22 | // It should ignore other people's exercises. |
| 23 | alice := filepath.Join(tmpDir, "users", "alice", "track-a", "exercise-one") |
| 24 | |
| 25 | // It should ignore nested dirs within exercises. |
| 26 | nested := filepath.Join(a1, "subdir", "deeper-dir", "another-deep-dir") |
| 27 | |
| 28 | for _, path := range []string{a1, b1, b2, alice, nested} { |
| 29 | err := os.MkdirAll(path, os.FileMode(0755)) |
| 30 | assert.NoError(t, err) |
| 31 | } |
| 32 | |
| 33 | ws, err := New(tmpDir) |
| 34 | assert.NoError(t, err) |
| 35 | |
| 36 | exercises, err := ws.PotentialExercises() |
| 37 | assert.NoError(t, err) |
| 38 | if assert.Equal(t, 3, len(exercises)) { |
| 39 | paths := make([]string, len(exercises)) |
| 40 | for i, e := range exercises { |
| 41 | paths[i] = e.Path() |
| 42 | } |
| 43 | |
| 44 | sort.Strings(paths) |
| 45 | assert.Equal(t, paths[0], "track-a/exercise-one") |
| 46 | assert.Equal(t, paths[1], "track-b/exercise-one") |
| 47 | assert.Equal(t, paths[2], "track-b/exercise-two") |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestWorkspaceExercises(t *testing.T) { |
| 52 | tmpDir, err := os.MkdirTemp("", "walk-with-metadata") |
nothing calls this directly
no test coverage detected