mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-02-11 13:53:53 +02:00
Let json patcher fail if file not found (#1694)
Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
This commit is contained in:
parent
0d1b94adb3
commit
8f9ed0766c
@ -19,12 +19,12 @@ func jsonApplyPatch(config jsonApplyPatchOptions, telemetryData *telemetry.Custo
|
||||
func runJsonApplyPatch(config *jsonApplyPatchOptions, fileUtils piperutils.FileUtils) error {
|
||||
schema, err := fileUtils.FileRead(config.Input)
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
patchFile, err := fileUtils.FileRead(config.Patch)
|
||||
if err != nil {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
patcher, err := jsonpatch.DecodePatch(patchFile)
|
||||
if err != nil {
|
||||
|
@ -79,4 +79,15 @@ func TestSchemaPatch(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.JSONEq(t, string(patchedSchema), string(patchedSchemaResult))
|
||||
})
|
||||
|
||||
t.Run("file does not exist", func(t *testing.T) {
|
||||
options := jsonApplyPatchOptions{
|
||||
Input: "schema.json",
|
||||
Patch: "patch.json",
|
||||
Output: "output.json",
|
||||
}
|
||||
filesMock := mock.FilesMock{}
|
||||
err := runJsonApplyPatch(&options, &filesMock)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user