From 09df007eb90e9662aada1e1a79b7151857aaeb69 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 29 Apr 2025 16:37:46 +0000 Subject: [PATCH] test/mocks: add cockpit modify Add the `modify` file function which performs atomic modifications to a file. --- src/test/mocks/cockpit/cockpitFile.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/mocks/cockpit/cockpitFile.ts b/src/test/mocks/cockpit/cockpitFile.ts index 731b575a..cbd8be1f 100644 --- a/src/test/mocks/cockpit/cockpitFile.ts +++ b/src/test/mocks/cockpit/cockpitFile.ts @@ -32,7 +32,7 @@ export const getLastBlueprintReq = () => { return lastRequest.blueprints[lastRequest.blueprints.length - 1]; }; -export const cockpitFile = (filepath: string) => { +export const cockpitFile = (filepath: string, options?: object) => { return { read: (): Promise => { const file = path.parse(filepath); @@ -52,5 +52,10 @@ export const cockpitFile = (filepath: string) => { lastRequest.blueprints.push(contents); } }, + modify: (callback: (contents: string) => string): Promise => { + return new Promise((resolve) => { + resolve(callback('')); + }); + }, }; };