Collect previous history for artifact prerequisites
This commit is contained in:
@@ -455,7 +455,6 @@ func TestNeedsObjectStoreForRunPrepareWithPreviousRequirements(t *testing.T) {
|
||||
Scriptorium: &config.ScriptoriumConfig{
|
||||
Artifacts: map[string]config.ScriptoriumArtifactConfig{
|
||||
"session_recap": {
|
||||
Enabled: true,
|
||||
Inputs: map[string]config.ScriptoriumInputConfig{
|
||||
"previous_recap": {
|
||||
Source: "narratio.previous_session.artifact.session_recap",
|
||||
@@ -471,8 +470,12 @@ func TestNeedsObjectStoreForRunPrepareWithPreviousRequirements(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
cfg.Pipeline.Scriptorium.Artifacts["child"] = config.ScriptoriumArtifactConfig{Enabled: true, DependsOn: []string{"session_recap"}}
|
||||
cfg.ArtifactCatalog = &config.ArtifactCatalog{Artifacts: cfg.Pipeline.Scriptorium.Artifacts}
|
||||
got := needsObjectStoreForRun(cfg, []stage.Stage{countingStage{name: "prepare", runs: new(int)}})
|
||||
got, err := needsObjectStoreForRun(cfg, []stage.Stage{countingStage{name: "prepare", runs: new(int)}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got != tt.want {
|
||||
t.Fatalf("needsObjectStoreForRun() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -1553,3 +1556,27 @@ func projectedTestPlayers(t *testing.T, party *config.CanonicalParty) []byte {
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func TestNeedsObjectStoreRespectsSelectedPrerequisites(t *testing.T) {
|
||||
definitions := map[string]config.ScriptoriumArtifactConfig{
|
||||
"child": {Enabled: true, DependsOn: []string{"parent"}},
|
||||
"parent": {Inputs: map[string]config.ScriptoriumInputConfig{"history": {Source: "narratio.previous_session.artifact.history", Required: true}}},
|
||||
"other": {Enabled: true},
|
||||
}
|
||||
cfg := &config.Config{Pipeline: &config.PipelineConfig{Scriptorium: &config.ScriptoriumConfig{Artifacts: definitions}}, Session: &config.SessionConfig{PreviousSessionID: "previous"}, ArtifactCatalog: &config.ArtifactCatalog{Artifacts: definitions}}
|
||||
for _, tc := range []struct {
|
||||
selected string
|
||||
want bool
|
||||
}{{"child", true}, {"other", false}} {
|
||||
t.Run(tc.selected, func(t *testing.T) {
|
||||
effective, err := artifacts.ResolveEffectiveArtifactSet(artifacts.ConfiguredArtifactDefinitions(definitions), []string{tc.selected})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := needsObjectStoreForRun(cfg, []stage.Stage{countingStage{name: "prepare", runs: new(int)}}, effective)
|
||||
if err != nil || got != tc.want {
|
||||
t.Fatalf("store needed = %v, error = %v", got, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user