test/mocks: add cockpit modify

Add the `modify` file function which performs atomic modifications to a
file.
This commit is contained in:
Gianluca Zuccarelli 2025-04-29 16:37:46 +00:00 committed by Sanne Raymaekers
parent c55706b931
commit 09df007eb9

View file

@ -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<string> => {
const file = path.parse(filepath);
@ -52,5 +52,10 @@ export const cockpitFile = (filepath: string) => {
lastRequest.blueprints.push(contents);
}
},
modify: (callback: (contents: string) => string): Promise<string> => {
return new Promise((resolve) => {
resolve(callback(''));
});
},
};
};