(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | } |
nothing calls this directly
no test coverage detected