MCPcopy Create free account
hub / github.com/exercism/cli / TestExerciseDir

Function TestExerciseDir

workspace/workspace_test.go:90–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func 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}

Callers

nothing calls this directly

Calls 3

ExerciseDirMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected