You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +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:
		| @@ -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) | ||||
| 	}) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user