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

Function TestConfigureWorkspace

cmd/configure_test.go:251–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

249}
250
251func TestConfigureWorkspace(t *testing.T) {
252 co := newCapturedOutput()
253 co.override()
254 defer co.reset()
255
256 testCases := []struct {
257 desc string
258 configured string
259 args []string
260 expected string
261 message string
262 err bool
263 }{
264 {
265 desc: "It doesn't lose a configured value",
266 configured: "/the-workspace",
267 args: []string{"--no-verify"},
268 expected: "/the-workspace",
269 },
270 {
271 desc: "It writes a workspace when passed as a flag",
272 configured: "",
273 args: []string{"--no-verify", "--workspace", "/new-workspace"},
274 expected: "/new-workspace",
275 },
276 {
277 desc: "It overwrites the configured workspace",
278 configured: "/configured-workspace",
279 args: []string{"--no-verify", "--workspace", "/replacement-workspace"},
280 expected: "/replacement-workspace",
281 },
282 {
283 desc: "It gets the default workspace when neither configured nor passed as a flag",
284 configured: "",
285 args: []string{"--token", "some-token"}, // need to bypass the error message on "bare configure"
286 expected: "/home/default-workspace",
287 },
288 {
289 desc: "It resolves the passed workspace to expand ~",
290 configured: "",
291 args: []string{"--workspace", "~/workspace-dir"},
292 expected: "/home/workspace-dir",
293 },
294
295 {
296 desc: "It resolves the configured workspace to expand ~",
297 configured: "~/configured-dir",
298 args: []string{"--token", "some-token"}, // need to bypass the error message on "bare configure"
299 expected: "/home/configured-dir", // The configuration object hard-codes the home directory below
300 },
301 }
302
303 endpoint := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
304 // 200 OK by default. Ping and TokenAuth will both pass.
305 })
306 ts := httptest.NewServer(endpoint)
307 defer ts.Close()
308

Callers

nothing calls this directly

Calls 5

newCapturedOutputFunction · 0.85
setupConfigureFlagsFunction · 0.85
runConfigureFunction · 0.85
overrideMethod · 0.80
resetMethod · 0.80

Tested by

no test coverage detected