MCPcopy
hub / github.com/pocketbase/pocketbase / TestStatic

Function TestStatic

apis/base_test.go:71–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func 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,

Callers

nothing calls this directly

Calls 8

CleanupMethod · 0.95
NewTestAppFunction · 0.92
StaticFunction · 0.92
ToApiErrorFunction · 0.92
createTestDirFunction · 0.70
RemoveAllMethod · 0.45
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…