(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestExerciseDir(t *testing.T) { |
| 91 | _, cwd, _, _ := runtime.Caller(0) |
| 92 | root := filepath.Join(cwd, "..", "..", "fixtures", "solution-dir") |
| 93 | |
| 94 | ws, err := New(filepath.Join(root, "workspace")) |
| 95 | assert.NoError(t, err) |
| 96 | |
| 97 | tests := []struct { |
| 98 | path string |
| 99 | ok bool |
| 100 | }{ |
| 101 | { |
| 102 | path: filepath.Join(ws.Dir, "exercise"), |
| 103 | ok: true, |
| 104 | }, |
| 105 | { |
| 106 | path: filepath.Join(ws.Dir, "exercise", "file.txt"), |
| 107 | ok: true, |
| 108 | }, |
| 109 | { |
| 110 | path: filepath.Join(ws.Dir, "exercise", "in", "a", "subdir", "file.txt"), |
| 111 | ok: true, |
| 112 | }, |
| 113 | { |
| 114 | path: filepath.Join(ws.Dir, "exercise", "in", "a"), |
| 115 | ok: true, |
| 116 | }, |
| 117 | { |
| 118 | path: filepath.Join(ws.Dir, "not-exercise", "file.txt"), |
| 119 | ok: false, |
| 120 | }, |
| 121 | { |
| 122 | path: filepath.Join(root, "file.txt"), |
| 123 | ok: false, |
| 124 | }, |
| 125 | { |
| 126 | path: filepath.Join(ws.Dir, "exercise", "no-such-file.txt"), |
| 127 | ok: false, |
| 128 | }, |
| 129 | } |
| 130 | |
| 131 | for _, test := range tests { |
| 132 | dir, err := ws.ExerciseDir(test.path) |
| 133 | if !test.ok { |
| 134 | assert.Error(t, err, test.path) |
| 135 | continue |
| 136 | } |
| 137 | assert.Equal(t, filepath.Join(ws.Dir, "exercise"), dir, test.path) |
| 138 | } |
| 139 | } |
nothing calls this directly
no test coverage detected