1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add global override for randomBytes

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-12 16:15:28 -05:00
parent 26b10b8738
commit bbb610ec69
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,17 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getGlobalOverride } from "../test-utils/get-global-override";
import randomBytesInjectable from "./random-bytes.injectable";
export default getGlobalOverride(randomBytesInjectable, () => async (size) => {
const res = Buffer.alloc(size);
for (let i = 0; i < size; i += 1) {
res[i] = i;
}
return res;
});

View File

@ -11,6 +11,7 @@ export type RandomBytes = (size: number) => Promise<Buffer>;
const randomBytesInjectable = getInjectable({
id: "random-bytes",
instantiate: (): RandomBytes => promisify(randomBytes),
causesSideEffects: true,
});
export default randomBytesInjectable;