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

Function TestNormalizedDocumentPath

workspace/document_test.go:11–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNormalizedDocumentPath(t *testing.T) {
12 root, err := os.MkdirTemp("", "docpath")
13 assert.NoError(t, err)
14 defer os.RemoveAll(root)
15
16 err = os.MkdirAll(filepath.Join(root, "subdirectory"), os.FileMode(0755))
17 assert.NoError(t, err)
18
19 testCases := []struct {
20 filepath string
21 path string
22 }{
23 {
24 filepath: filepath.Join(root, "file.txt"),
25 path: "file.txt",
26 },
27 {
28 filepath: filepath.Join(root, "subdirectory", "file.txt"),
29 path: "subdirectory/file.txt",
30 },
31 }
32
33 for _, tc := range testCases {
34 err = os.WriteFile(tc.filepath, []byte("a file"), os.FileMode(0600))
35 assert.NoError(t, err)
36
37 doc, err := NewDocument(root, tc.filepath)
38 assert.NoError(t, err)
39
40 assert.Equal(t, doc.Path(), tc.path)
41 }
42}

Callers

nothing calls this directly

Calls 2

PathMethod · 0.95
NewDocumentFunction · 0.85

Tested by

no test coverage detected