(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestStatic(t *testing.T) { |
| 72 | t.Parallel() |
| 73 | |
| 74 | app, _ := tests.NewTestApp() |
| 75 | defer app.Cleanup() |
| 76 | |
| 77 | dir := createTestDir(t) |
| 78 | defer os.RemoveAll(dir) |
| 79 | |
| 80 | fsys := os.DirFS(filepath.Join(dir, "sub")) |
| 81 | |
| 82 | type staticScenario struct { |
| 83 | path string |
| 84 | indexFallback bool |
| 85 | expectedStatus int |
| 86 | expectBody string |
| 87 | expectError bool |
| 88 | } |
| 89 | |
| 90 | scenarios := []staticScenario{ |
| 91 | { |
| 92 | path: "", |
| 93 | indexFallback: false, |
| 94 | expectedStatus: 200, |
| 95 | expectBody: "sub index.html", |
| 96 | expectError: false, |
| 97 | }, |
| 98 | { |
| 99 | path: "missing/a/b/c", |
| 100 | indexFallback: false, |
| 101 | expectedStatus: 404, |
| 102 | expectBody: "", |
| 103 | expectError: true, |
| 104 | }, |
| 105 | { |
| 106 | path: "missing/a/b/c", |
| 107 | indexFallback: true, |
| 108 | expectedStatus: 200, |
| 109 | expectBody: "sub index.html", |
| 110 | expectError: false, |
| 111 | }, |
| 112 | { |
| 113 | path: "testroot", // parent directory file |
| 114 | indexFallback: false, |
| 115 | expectedStatus: 404, |
| 116 | expectBody: "", |
| 117 | expectError: true, |
| 118 | }, |
| 119 | { |
| 120 | path: "test", |
| 121 | indexFallback: false, |
| 122 | expectedStatus: 200, |
| 123 | expectBody: "sub test", |
| 124 | expectError: false, |
| 125 | }, |
| 126 | { |
| 127 | path: "sub2", |
| 128 | indexFallback: false, |
nothing calls this directly
no test coverage detected
searching dependent graphs…