Add native Notarius readiness checks
This commit is contained in:
@@ -151,3 +151,51 @@ func TestDownstreamTargetSelectionForPolish(t *testing.T) {
|
||||
t.Fatalf("validation targets: %+v %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownstreamTargetSelectionForNotarius(t *testing.T) {
|
||||
cfg := &config.Config{Pipeline: &config.PipelineConfig{Notarius: &config.NotariusConfig{Enabled: true}}}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
stages []projectedStage
|
||||
want bool
|
||||
}{
|
||||
{"selected", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"reused", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionSkip}}}, false},
|
||||
{"unrelated", []projectedStage{{Name: "analyze", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got, err := executionDownstreamTargets(cfg, "session", &workProjection{Stages: tc.stages})
|
||||
if err != nil || got.Notarius != tc.want {
|
||||
t.Fatalf("targets = %#v, %v", got, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
got, err := validationDownstreamTargets(cfg, "session")
|
||||
if err != nil || !got.Notarius {
|
||||
t.Fatalf("validation targets = %#v, %v", got, err)
|
||||
}
|
||||
cfg.Pipeline.Notarius.Enabled = false
|
||||
got, err = validationDownstreamTargets(cfg, "session")
|
||||
if err != nil || got.Notarius {
|
||||
t.Fatalf("disabled targets = %#v, %v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusPreflightUsesCurrentTranscriptOnlyWhenUpstreamIsReused(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
stages []projectedStage
|
||||
want bool
|
||||
}{
|
||||
{"extract only", []projectedStage{{Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"reused trim", []projectedStage{{Name: "trim", Decision: preExecutionDecision{action: stageActionSkip}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, true},
|
||||
{"running trim", []projectedStage{{Name: "trim", Decision: preExecutionDecision{action: stageActionRun}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
{"running polish", []projectedStage{{Name: "polish", Decision: preExecutionDecision{action: stageActionRun}}, {Name: "extract", Decision: preExecutionDecision{action: stageActionRun}}}, false},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := currentTranscriptUsableForNotarius(&workProjection{Stages: tc.stages}); got != tc.want {
|
||||
t.Fatalf("got %v, want %v", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user