package topdata import ( "net/http" "net/http/httptest" "testing" ) // stubEmptyPartsManifest points the released-parts-manifest fetch at a local // httptest server that serves an empty (but structurally valid) manifest, so a // build/compare test exercises native build behaviour without reaching the live // Gitea host. Use it in tests that build the non-optional `parts` consumer but // do not depend on any released part rows. // // It is per-test (t.Setenv) on purpose: a package-global SOW_ASSETS_SERVER_URL // would override the git-remote-derived server that other tests configure. func stubEmptyPartsManifest(t *testing.T) { t.Helper() var srv *httptest.Server srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/api/v1/repos/ShadowsOverWestgate/sow-assets/releases/tags/parts-manifest-current": w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{"assets":[{"name":"sow-parts-manifest.json","browser_download_url":"` + srv.URL + `/dl/sow-parts-manifest.json"}]}`)) case "/dl/sow-parts-manifest.json": w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{"repo":"ShadowsOverWestgate/sow-assets","ref":"main","categories":{"belt":[],"bicep":[],"chest":[],"foot":[],"forearm":[],"leg":[],"neck":[],"pelvis":[],"robe":[],"shin":[],"shoulder":[]}}`)) default: http.NotFound(w, r) } })) t.Cleanup(srv.Close) t.Setenv("SOW_ASSETS_SERVER_URL", srv.URL) t.Setenv("SOW_ASSETS_REPO", "ShadowsOverWestgate/sow-assets") }