fix(02-03): resolve relative seed specs and skip only recorded seeds
Manifest seed paths are fixtures-relative. Skip re-hitting the backend only when every seed step already has a recorded status so a hand-written spec can be recorded in place. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -365,3 +365,44 @@ func TestCoveragePendingMismatchDoesNotFail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecordSeedResolvesRelativeSpec(t *testing.T) {
|
||||
fixtures := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(fixtures, "seed"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
spec := Flow{Version: 1, Name: "seed", Steps: []Step{{
|
||||
ID: "ok",
|
||||
Request: Request{Method: http.MethodGet, Path: "/seed"},
|
||||
}}}
|
||||
if err := SaveFlow(filepath.Join(fixtures, "seed", "bootstrap.yaml"), spec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hits := 0
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
hits++
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"ok":true}`))
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
m := Manifest{
|
||||
Version: 1,
|
||||
AuthGroups: []string{"public"},
|
||||
Seed: &Seed{Spec: "seed/bootstrap.yaml", Fixture: "seed/bootstrap.yaml"},
|
||||
Routes: []Route{{
|
||||
ID: "GET /later public", Method: http.MethodGet, Path: "/later",
|
||||
AuthGroup: "public", Status: StatusPending,
|
||||
}},
|
||||
}
|
||||
if _, err := RecordManifest(context.Background(), m, ManifestConfig{Target: srv.URL, Fixtures: fixtures}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if hits != 1 {
|
||||
t.Fatalf("seed hits %d", hits)
|
||||
}
|
||||
if _, err := RecordManifest(context.Background(), m, ManifestConfig{Target: srv.URL, Fixtures: fixtures}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if hits != 1 {
|
||||
t.Fatalf("existing seed must not re-hit PHP: %d", hits)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user