Remove legacy distributor report path config
This commit is contained in:
@@ -58,12 +58,6 @@ func TestDefaults(t *testing.T) {
|
||||
if cfg.Notify.Distributor.IdempotencyKeyTemplate != "{bundle_id}.{run_id}" {
|
||||
t.Fatalf("Notify.Distributor.IdempotencyKeyTemplate = %q, want default", cfg.Notify.Distributor.IdempotencyKeyTemplate)
|
||||
}
|
||||
wantReportPaths := []string{
|
||||
"{valid_start_date}/{artifact_group}/{valid_start_date}-{artifact_group}-{run_id}.md",
|
||||
}
|
||||
if strings.Join(cfg.Notify.Distributor.ReportPathTemplates, "\n") != strings.Join(wantReportPaths, "\n") {
|
||||
t.Fatalf("Notify.Distributor.ReportPathTemplates = %#v, want %#v", cfg.Notify.Distributor.ReportPathTemplates, wantReportPaths)
|
||||
}
|
||||
if !cfg.Notify.Distributor.Batch.Enabled {
|
||||
t.Fatalf("Notify.Distributor.Batch.Enabled = false, want true")
|
||||
}
|
||||
@@ -102,9 +96,6 @@ func TestLoadExampleConfig(t *testing.T) {
|
||||
if cfg.Notify.Distributor.PipelineIDTemplate != "weatherreporter.{report_id}" {
|
||||
t.Fatalf("PipelineIDTemplate = %q, want example pipeline template", cfg.Notify.Distributor.PipelineIDTemplate)
|
||||
}
|
||||
if len(cfg.Notify.Distributor.ReportPathTemplates) != 1 {
|
||||
t.Fatalf("ReportPathTemplates = %#v, want example archive path", cfg.Notify.Distributor.ReportPathTemplates)
|
||||
}
|
||||
if !cfg.Notify.Distributor.Batch.Enabled {
|
||||
t.Fatalf("Notify.Distributor.Batch.Enabled = false, want true")
|
||||
}
|
||||
@@ -1065,6 +1056,37 @@ func TestDisabledDistributorNotifyAcceptsOmittedFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistributorNotifyRejectsRemovedGlobalReportPaths(t *testing.T) {
|
||||
removedField := "report_path" + "_templates"
|
||||
_, err := LoadFile(writeConfig(t, `
|
||||
notify:
|
||||
distributor:
|
||||
`+removedField+`:
|
||||
- index.md
|
||||
`))
|
||||
if err == nil {
|
||||
t.Fatal("LoadFile() error = nil, want removed global path field error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), `unknown notify distributor field "`+removedField+`"`) {
|
||||
t.Fatalf("error = %q, want removed global path field rejection", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistributorNotifyRejectsUnknownFields(t *testing.T) {
|
||||
_, err := LoadFile(writeConfig(t, `
|
||||
notify:
|
||||
distributor:
|
||||
paths:
|
||||
- index.md
|
||||
`))
|
||||
if err == nil {
|
||||
t.Fatal("LoadFile() error = nil, want unknown distributor field error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), `unknown notify distributor field "paths"`) {
|
||||
t.Fatalf("error = %q, want unknown field rejection", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisabledDistributorNotifyAcceptsMalformedBatchTemplates(t *testing.T) {
|
||||
cfg := Defaults()
|
||||
cfg.Notify.Distributor.Enabled = false
|
||||
@@ -1154,32 +1176,11 @@ func TestEnabledDistributorNotifyValidation(t *testing.T) {
|
||||
wantErr: "notify.distributor.idempotency_key_template",
|
||||
},
|
||||
{
|
||||
name: "ReportPathTemplatesEmpty",
|
||||
name: "BatchTemplate",
|
||||
mutate: func(cfg *Config) {
|
||||
cfg.Notify.Distributor.ReportPathTemplates = nil
|
||||
cfg.Notify.Distributor.Batch.BundleIDTemplate = "{run_id}"
|
||||
},
|
||||
wantErr: "notify.distributor.report_path_templates",
|
||||
},
|
||||
{
|
||||
name: "ReportPathTemplateUnknown",
|
||||
mutate: func(cfg *Config) {
|
||||
cfg.Notify.Distributor.ReportPathTemplates = []string{"{unknown}"}
|
||||
},
|
||||
wantErr: "notify.distributor.report_path_templates",
|
||||
},
|
||||
{
|
||||
name: "ReportPathTemplateInvalidPath",
|
||||
mutate: func(cfg *Config) {
|
||||
cfg.Notify.Distributor.ReportPathTemplates = []string{"/{batch_output_name}"}
|
||||
},
|
||||
wantErr: "notify.distributor.report_path_templates",
|
||||
},
|
||||
{
|
||||
name: "ReportPathTemplateDuplicatePath",
|
||||
mutate: func(cfg *Config) {
|
||||
cfg.Notify.Distributor.ReportPathTemplates = []string{"latest.md", "latest.md"}
|
||||
},
|
||||
wantErr: "notify.distributor.report_path_templates",
|
||||
wantErr: "notify.distributor.batch.bundle_id_template",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user