MCPcopy Create free account
hub / github.com/compozy/agh / firstEmbeddedAsset

Function firstEmbeddedAsset

internal/api/httpapi/static_test.go:169–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func firstEmbeddedAsset(t *testing.T) (string, []byte) {
170 t.Helper()
171
172 staticFS := mustStaticFS(t)
173 entries, err := fs.ReadDir(staticFS, "assets")
174 if err != nil {
175 t.Fatalf("fs.ReadDir(assets) error = %v", err)
176 }
177
178 for _, entry := range entries {
179 if entry.IsDir() {
180 continue
181 }
182 switch ext := path.Ext(entry.Name()); ext {
183 case ".js", ".css":
184 assetPath := path.Join("assets", entry.Name())
185 data, readErr := fs.ReadFile(staticFS, assetPath)
186 if readErr != nil {
187 t.Fatalf("fs.ReadFile(%s) error = %v", assetPath, readErr)
188 }
189 return "/" + assetPath, data
190 }
191 }
192
193 t.Fatal("expected at least one embedded .js or .css asset")
194 return "", nil
195}
196
197func writeLocalStaticDist(t *testing.T, indexMarker string, assets map[string]string) string {
198 t.Helper()

Callers 1

Calls 3

mustStaticFSFunction · 0.85
NameMethod · 0.65
ReadFileMethod · 0.65

Tested by

no test coverage detected