44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
|
|
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
|
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
|
)
|
|
|
|
func setCurrentBuiltInEvidence(t *testing.T, m *manifest.Manifest, stage, kind, sourceID, path string) {
|
|
t.Helper()
|
|
checksum, err := artifacts.SHA256File(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m.MarkStageSucceeded(stage, time.Date(2026, 5, 16, 1, 2, 3, 0, time.UTC), []manifest.ArtifactRecord{{
|
|
Kind: kind, SourceID: sourceID, LocalPath: path, ProducerRunID: stage + "-run", Checksum: checksum,
|
|
}})
|
|
}
|
|
|
|
func seedCurrentBuiltInEvidence(t *testing.T, manifestPath, sessionID, campaign, stage, kind, sourceID, path string) {
|
|
t.Helper()
|
|
m := manifest.New(sessionID, time.Now().UTC())
|
|
m.Campaign = campaign
|
|
setCurrentBuiltInEvidence(t, m, stage, kind, sourceID, path)
|
|
if err := (&manifest.LocalStore{}).Save(context.Background(), manifestPath, m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func setCurrentPreviousArtifactInput(t *testing.T, m *manifest.Manifest, path string) {
|
|
t.Helper()
|
|
checksum, err := artifacts.SHA256File(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m.Inputs = append(m.Inputs, manifest.InputRecord{
|
|
Kind: "previous_artifact", Source: artifactpolicy.PreviousSessionSourceID("session_recap"), Path: path, Checksum: checksum,
|
|
})
|
|
}
|