feat(project): add cdn_channel AutogenSourceConfig + validation
This commit is contained in:
@@ -1796,6 +1796,31 @@ func TestCloneWithHAKNamesRejectsUnknownHAKs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateAutogenConsumerSourcesCDNChannel(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
source AutogenSourceConfig
|
||||
wantFail bool
|
||||
}{
|
||||
{"valid", AutogenSourceConfig{Kind: "cdn_channel", ChannelsPath: "releases/haks/channels.json", ManifestPath: "releases/haks/{tag}/vfxs.yml"}, false},
|
||||
{"missing channels_path", AutogenSourceConfig{Kind: "cdn_channel", ManifestPath: "releases/haks/{tag}/vfxs.yml"}, true},
|
||||
{"missing manifest_path", AutogenSourceConfig{Kind: "cdn_channel", ChannelsPath: "releases/haks/channels.json"}, true},
|
||||
{"manifest_path lacks {tag}", AutogenSourceConfig{Kind: "cdn_channel", ChannelsPath: "releases/haks/channels.json", ManifestPath: "releases/haks/vfxs.yml"}, true},
|
||||
{"empty kind is ignored", AutogenSourceConfig{}, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
failures := validateAutogenConsumerSources([]AutogenConsumerConfig{{ID: "x", Source: tc.source}})
|
||||
if tc.wantFail && len(failures) == 0 {
|
||||
t.Fatalf("expected validation failure, got none")
|
||||
}
|
||||
if !tc.wantFail && len(failures) != 0 {
|
||||
t.Fatalf("expected no failure, got %v", failures)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func loadAndValidate(root string) error {
|
||||
proj, err := Load(root)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user