41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
|
|
package artifacts
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||
|
|
"slices"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestConfiguredArtifactOrderWideFanout(t *testing.T) {
|
||
|
|
items := map[string]config.ScriptoriumArtifactConfig{"root": {}}
|
||
|
|
want := []string{"root"}
|
||
|
|
for i := 0; i < 64; i++ {
|
||
|
|
key := fmt.Sprintf("child_%03d", i)
|
||
|
|
items[key] = config.ScriptoriumArtifactConfig{DependsOn: []string{"root"}}
|
||
|
|
want = append(want, key)
|
||
|
|
}
|
||
|
|
got, err := OrderConfiguredArtifacts(items)
|
||
|
|
if err != nil || strings.Join(got, ",") != strings.Join(want, ",") {
|
||
|
|
t.Fatalf("wide fanout order: %v, %v", got, err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestAnalyzeTargetClosureIncludesNestedPrerequisites(t *testing.T) {
|
||
|
|
configured := map[string]config.ScriptoriumArtifactConfig{
|
||
|
|
"summary": {Enabled: true, DependsOn: []string{" history ", "history"}},
|
||
|
|
"history": {DependsOn: []string{"base"}},
|
||
|
|
"base": {},
|
||
|
|
"other": {DependsOn: []string{"separate"}},
|
||
|
|
"separate": {},
|
||
|
|
}
|
||
|
|
got, err := AnalyzeTargetClosure(configured, []string{"summary"})
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
if want := []string{"base", "history", "summary"}; !slices.Equal(got, want) {
|
||
|
|
t.Fatalf("closure = %v, want %v", got, want)
|
||
|
|
}
|
||
|
|
}
|