feat(02-02): record manifest route cases and report coverage

Drive ordered route cases through RecordFlow, resume in batches of
15, and print recorded/passing/failing/unrecorded coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-17 12:36:48 +02:00
parent aa165fe3d0
commit 24c1f43e84
7 changed files with 1147 additions and 18 deletions

View File

@@ -1,8 +1,11 @@
package tide
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"net/http"
"os"
"path/filepath"
"strings"
)
@@ -84,6 +87,7 @@ type ReplayConfig struct {
Client *http.Client
MaxBody int64
Store *Store
BaseDir string
}
// Result is the outcome of replaying a flow.
@@ -169,6 +173,30 @@ func validateFlow(flow Flow) error {
return nil
}
func materializeSidecar(base string, resp *Response) error {
if resp == nil || resp.BodyFile == "" {
return nil
}
if err := validateSidecar(resp.BodyFile); err != nil {
return err
}
path := resp.BodyFile
if base != "" {
path = filepath.Join(base, resp.BodyFile)
}
raw, err := os.ReadFile(path)
if err != nil {
return fmt.Errorf("tide: read body_file %s: %w", resp.BodyFile, err)
}
sum := sha256.Sum256(raw)
got := hex.EncodeToString(sum[:])
if resp.SHA256 != "" && !strings.EqualFold(got, resp.SHA256) {
return fmt.Errorf("tide: body_file %s digest mismatch", resp.BodyFile)
}
resp.Body = Body(raw)
return nil
}
func validateSidecar(path string) error {
if path == "" {
return nil