1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00

improve error message when parsing config (#1387)

* improve error message when parsing config

* adjust test case

Co-authored-by: Florian Wilhelm <florian.wilhelm02@sap.com>
This commit is contained in:
Christopher Fenner 2020-04-09 13:40:04 +02:00 committed by GitHub
parent 6d5b634278
commit b0144614e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ func (c *Config) ReadConfig(configuration io.ReadCloser) error {
err = yaml.Unmarshal(content, &c)
if err != nil {
return NewParseError(fmt.Sprintf("error unmarshalling %q: %v", content, err))
return NewParseError(fmt.Sprintf("format of configuration is invalid %q: %v", content, err))
}
return nil
}

View File

@ -247,7 +247,7 @@ steps:
var c Config
myConfig := ioutil.NopCloser(strings.NewReader("invalid config"))
_, err := c.GetStepConfig(nil, "", myConfig, nil, StepFilters{}, []StepParameters{}, nil, nil, "stage1", "step1", []Alias{})
assert.EqualError(t, err, "failed to parse custom pipeline configuration: error unmarshalling \"invalid config\": error unmarshaling JSON: json: cannot unmarshal string into Go value of type config.Config", "default error expected")
assert.EqualError(t, err, "failed to parse custom pipeline configuration: format of configuration is invalid \"invalid config\": error unmarshaling JSON: json: cannot unmarshal string into Go value of type config.Config", "default error expected")
})
t.Run("Failure case defaults", func(t *testing.T) {