Use native configuration validation and diagnostics
This commit is contained in:
@@ -71,10 +71,10 @@ storage:
|
||||
if err == nil {
|
||||
t.Fatal("LoadPipeline() error = nil, want strict decode error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "strict decode failed") {
|
||||
if !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||
t.Fatalf("LoadPipeline() error = %v, want strict decode failed", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), tt.wantField) {
|
||||
if !strings.Contains(configurationErrorText(err), tt.wantField) {
|
||||
t.Fatalf("LoadPipeline() error = %v, want field %q", err, tt.wantField)
|
||||
}
|
||||
})
|
||||
@@ -90,7 +90,7 @@ func TestLegacyCredentialReferenceFieldsFailStrictDecode(t *testing.T) {
|
||||
}
|
||||
pipelinePath, _ := writeConfigFiles(t, pipelineYAML, testSessionBaseYAML)
|
||||
_, err := LoadPipeline(pipelinePath)
|
||||
if err == nil || !strings.Contains(err.Error(), field) || !strings.Contains(err.Error(), "strict decode") {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), field) || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||
t.Fatalf("LoadPipeline() error = %v, want strict rejection of %s", err, field)
|
||||
}
|
||||
})
|
||||
@@ -177,7 +177,7 @@ storage:
|
||||
if err == nil {
|
||||
err = ValidatePipelineConfig(cfg)
|
||||
}
|
||||
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), tt.wantErr) {
|
||||
t.Fatalf("Validate() error = %v, want to contain %q", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
@@ -270,7 +270,7 @@ inputs:
|
||||
err = Validate(cfg)
|
||||
}
|
||||
if tt.wantErr != "" {
|
||||
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), tt.wantErr) {
|
||||
t.Fatalf("Validate() error = %v, want %q", err, tt.wantErr)
|
||||
}
|
||||
return
|
||||
@@ -462,7 +462,7 @@ publish:
|
||||
if err == nil {
|
||||
err = Validate(cfg)
|
||||
}
|
||||
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), tt.wantErr) {
|
||||
t.Fatalf("Validate() error = %v, want to contain %q", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
@@ -482,7 +482,7 @@ publish:
|
||||
if err == nil {
|
||||
err = Validate(cfg)
|
||||
}
|
||||
if err == nil || !strings.Contains(err.Error(), "pipeline.publish.outputs[0].source") || !strings.Contains(err.Error(), "unsupported") {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "pipeline.publish.outputs[0].source") || !strings.Contains(configurationErrorText(err), "unsupported") {
|
||||
t.Fatalf("Validate() error = %v, want source field and unsupported category", err)
|
||||
}
|
||||
}
|
||||
@@ -614,7 +614,7 @@ publish:
|
||||
`
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, pipelineYAML, testSessionBaseYAML)
|
||||
_, err := Load(pipelinePath, sessionPath)
|
||||
if err == nil || !strings.Contains(err.Error(), "decode.unknown_field") {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||
t.Fatalf("Load() error = %v, want retired locks field rejected", err)
|
||||
}
|
||||
}
|
||||
@@ -628,7 +628,7 @@ publish:
|
||||
`
|
||||
pipelinePath, sessionPath := writeConfigFiles(t, pipelineYAML, testSessionBaseYAML)
|
||||
_, err := Load(pipelinePath, sessionPath)
|
||||
if err == nil || !strings.Contains(err.Error(), "strict decode failed") {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "decode.unknown_field") {
|
||||
t.Fatalf("Load() error = %v, want strict decode failed", err)
|
||||
}
|
||||
}
|
||||
@@ -708,7 +708,7 @@ storage:
|
||||
err = Validate(cfg)
|
||||
}
|
||||
if tt.wantErr != "" {
|
||||
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), tt.wantErr) {
|
||||
t.Fatalf("Validate() error = %v, want to contain %q", err, tt.wantErr)
|
||||
}
|
||||
return
|
||||
@@ -742,7 +742,7 @@ inputs:
|
||||
}
|
||||
|
||||
err = Validate(cfg)
|
||||
if err == nil || !strings.Contains(err.Error(), "pipeline.storage.s3.bucket is required") {
|
||||
if err == nil || !strings.Contains(configurationErrorText(err), "pipeline.storage.s3.bucket is required") {
|
||||
t.Fatalf("Validate() error = %v, want bucket requirement", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user