test/mocks: add cockpit modify
Add the `modify` file function which performs atomic modifications to a file.
This commit is contained in:
parent
c55706b931
commit
09df007eb9
1 changed files with 6 additions and 1 deletions
|
|
@ -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(''));
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue