Share downstream readiness checks across invocations
This commit is contained in:
48
internal/app/downstream_readiness_test.go
Normal file
48
internal/app/downstream_readiness_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/scriptorium"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/preflight"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||
)
|
||||
|
||||
func TestDownstreamReadinessContinuesAfterIndependentFailures(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
paths := seedValidationPrepared(t, cfg)
|
||||
m, present, err := loadManifestAtPathIfPresent(context.Background(), &manifest.LocalStore{}, paths.ManifestPath)
|
||||
if err != nil || !present {
|
||||
t.Fatalf("load manifest: %v", err)
|
||||
}
|
||||
scriptFailure := errors.New("requirements unavailable")
|
||||
auditaFailure := errors.New("provider unavailable")
|
||||
inspector := &scriptorium.FakeRunner{RequirementsErr: scriptFailure}
|
||||
provider := &audita.FakeRunner{PreflightErr: auditaFailure}
|
||||
runtime := &invocationRuntime{ctx: context.Background(), cfg: cfg, paths: paths, manifest: m, identity: invocationIdentity{RunID: "probe"}, env: &stage.Env{Scriptorium: inspector, Audita: provider}, dependencies: invocationDependencies{}.normalized()}
|
||||
result, err := checkDownstreamReadiness(runtime, preflight.Targets{Polish: true, Scriptorium: []preflight.Target{{Stage: "trim"}}}, true, false, false)
|
||||
if !errors.Is(err, scriptFailure) || !errors.Is(err, auditaFailure) || len(result.Checks) != 2 || len(result.Findings) != 2 || len(provider.PreflightRequests) != 1 {
|
||||
t.Fatalf("result = %+v, error = %v", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownstreamReadinessReportsRequestFailuresAndBlockedInputs(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
configureNotariusProbe(t, cfg)
|
||||
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
runtime := &invocationRuntime{ctx: context.Background(), cfg: cfg, paths: paths, identity: invocationIdentity{RunID: "probe"}, env: &stage.Env{Audita: &audita.FakeRunner{}}, dependencies: invocationDependencies{}.normalized()}
|
||||
targets := preflight.Targets{Polish: true, Notarius: true}
|
||||
result, err := checkDownstreamReadiness(runtime, targets, true, false, false)
|
||||
if err == nil || len(result.Checks) != 2 || result.Checks[0].Outcome != "failed" || result.Checks[1].Outcome != "failed" {
|
||||
t.Fatalf("result = %+v, error = %v", result, err)
|
||||
}
|
||||
result, err = checkDownstreamReadiness(runtime, targets, false, false, false)
|
||||
if err != nil || len(result.Checks) != 2 || result.Checks[0].Outcome != "blocked" || result.Checks[1].Outcome != "blocked" {
|
||||
t.Fatalf("result = %+v, error = %v", result, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user