Skip to content

🎥 Make videos programmatically with React

fix lambda tests

Jonny Burgerb9c543caa15a
diff --git a/packages/it-tests/src/lambda/cli.test.ts b/packages/it-tests/src/lambda/cli.test.ts
deleted file mode 100644
index 73502daa4b..0000000000
--- a/packages/it-tests/src/lambda/cli.test.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import {
- CURRENT_VERSION,
- DEFAULT_MEMORY_SIZE,
- DEFAULT_TIMEOUT,
-} from "@remotion/lambda/dist/defaults";
-import { CliInternals } from "@remotion/cli";
-import { LambdaInternals } from "@remotion/lambda";
-import { getProcessWriteOutput } from "./console-hooks";
-
-test("Deploy function", async () => {
- await LambdaInternals.executeCommand(["functions", "deploy"]);
- expect(getProcessWriteOutput()).toContain(
- `Deployed as remotion-render-${CURRENT_VERSION}-${DEFAULT_MEMORY_SIZE}mb-${DEFAULT_TIMEOUT}sec\n`
- );
-});
-
-test("Deploy function and list it", async () => {
- await LambdaInternals.executeCommand(["functions", "deploy"]);
- await LambdaInternals.executeCommand(["functions", "ls"]);
- expect(getProcessWriteOutput()).toContain("Getting functions...");
- expect(getProcessWriteOutput()).toContain("Memory (MB)");
- expect(getProcessWriteOutput()).toMatch(/remotion-render-(.*)\s+2048\s+120/g);
-});
-
-test("Deploy function and it already exists should fail", async () => {
- await LambdaInternals.executeCommand(["functions", "deploy"]);
- await LambdaInternals.executeCommand(["functions", "deploy"]);
-
- expect(getProcessWriteOutput()).toMatch(/Already exists as remotion-render/);
-});
-
-test('If no functions are there and is quiet, should return "()"', async () => {
- CliInternals.parsedCli.q = true;
- await LambdaInternals.executeCommand(["functions", "ls"]);
- expect(getProcessWriteOutput()).toBe("()");
-});
-
-test("Should handle functions rm called with no functions", async () => {
- await LambdaInternals.executeCommand(["functions", "rm", "()"]);
- expect(getProcessWriteOutput()).toBe("No functions to remove.");
-});
diff --git a/packages/it-tests/src/lambda/console-hooks.ts b/packages/it-tests/src/lambda/console-hooks.ts
deleted file mode 100644
index 4110eb1544..0000000000
--- a/packages/it-tests/src/lambda/console-hooks.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { Internals } from "remotion";
-import { cleanFnStore } from "../../../lambda/src/api/mock-functions";
-
-let stdoutOutput: string[] = [];
-let stderrOutput: string[] = [];
-
-export const getProcessWriteOutput = () => {
- return stdoutOutput
- .filter(Internals.truthy)
- .map((c) => c.toString())
- .join("\n");
-};
-export const getProcessStdErrOutput = () => {
- return stderrOutput
- .filter(Internals.truthy)
- .map((c) => c.toString())
- .join("\n");
-};
-
-const originalStdout = process.stdout.write;
-const originalConsoleLog = console.log;
-const originalConsoleError = console.error;
-const originalStderr = process.stderr.write;
-
-beforeEach(() => {
- stdoutOutput = [];
- stderrOutput = [];
- cleanFnStore();
- // @ts-expect-error
- process.stdout.write = (str: string) => {
- //originalStdout(str);
- stdoutOutput.push(str);
- };
- console.log = (str: string) => {
- //originalStdout(str);
- stdoutOutput.push(str);
- };
- console.error = (str: string) => {
- //originalStderr(str);
- stderrOutput.push(str);
- };
-
- // @ts-expect-error
- process.stderr.write = (str: string) => {
- // originalStderr(str);
- stderrOutput.push(str);
- };
-});
-
-afterEach(() => {
- process.stdout.write = originalStdout;
- process.stderr.write = originalStderr;
- console.log = originalConsoleLog;
- console.error = originalConsoleError;
-});
diff --git a/packages/lambda/src/test/integration/cli.test.ts b/packages/lambda/src/test/integration/cli.test.ts
new file mode 100644
index 0000000000..230ae11caa
--- /dev/null
+++ b/packages/lambda/src/test/integration/cli.test.ts
@@ -0,0 +1,41 @@
+import {CliInternals} from '@remotion/cli';
+import {
+ CURRENT_VERSION,
+ DEFAULT_MEMORY_SIZE,
+ DEFAULT_TIMEOUT,
+} from '../../defaults';
+import {LambdaInternals} from '../../internals';
+import {getProcessWriteOutput} from './console-hooks';
+
+test('Deploy function', async () => {
+ await LambdaInternals.executeCommand(['functions', 'deploy']);
+ expect(getProcessWriteOutput()).toContain(
+ `Deployed as remotion-render-${CURRENT_VERSION}-${DEFAULT_MEMORY_SIZE}mb-${DEFAULT_TIMEOUT}sec\n`
+ );
+});
+
+test('Deploy function and list it', async () => {
+ await LambdaInternals.executeCommand(['functions', 'deploy']);
+ await LambdaInternals.executeCommand(['functions', 'ls']);
+ expect(getProcessWriteOutput()).toContain('Getting functions...');
+ expect(getProcessWriteOutput()).toContain('Memory (MB)');
+ expect(getProcessWriteOutput()).toMatch(/remotion-render-(.*)\s+2048\s+120/g);
+});
+
+test('Deploy function and it already exists should fail', async () => {
+ await LambdaInternals.executeCommand(['functions', 'deploy']);
+ await LambdaInternals.executeCommand(['functions', 'deploy']);
+
+ expect(getProcessWriteOutput()).toMatch(/Already exists as remotion-render/);
+});
+
+test('If no functions are there and is quiet, should return "()"', async () => {
+ CliInternals.parsedCli.q = true;
+ await LambdaInternals.executeCommand(['functions', 'ls']);
+ expect(getProcessWriteOutput()).toBe('()');
+});
+
+test('Should handle functions rm called with no functions', async () => {
+ await LambdaInternals.executeCommand(['functions', 'rm', '()']);
+ expect(getProcessWriteOutput()).toBe('No functions to remove.');
+});
diff --git a/packages/lambda/src/test/integration/console-hooks.ts b/packages/lambda/src/test/integration/console-hooks.ts
new file mode 100644
index 0000000000..eae344e6f3
--- /dev/null
+++ b/packages/lambda/src/test/integration/console-hooks.ts
@@ -0,0 +1,58 @@
+import {Internals} from 'remotion';
+import {cleanFnStore} from '../../api/mock-functions';
+
+let stdoutOutput: string[] = [];
+let stderrOutput: string[] = [];
+
+export const getProcessWriteOutput = () => {
+ return stdoutOutput
+ .filter(Internals.truthy)
+ .map((c) => c.toString())
+ .join('\n');
+};
+
+export const getProcessStdErrOutput = () => {
+ return stderrOutput
+ .filter(Internals.truthy)
+ .map((c) => c.toString())
+ .join('\n');
+};
+
+const originalStdout = process.stdout.write;
+const originalConsoleLog = console.log;
+const originalConsoleError = console.error;
+const originalStderr = process.stderr.write;
+
+beforeEach(() => {
+ stdoutOutput = [];
+ stderrOutput = [];
+ cleanFnStore();
+ // @ts-expect-error
+ process.stdout.write = (str: string) => {
+ // originalStdout(str);
+ stdoutOutput.push(str);
+ };
+
+ console.log = (str: string) => {
+ // originalStdout(str);
+ stdoutOutput.push(str);
+ };
+
+ console.error = (str: string) => {
+ // originalStderr(str);
+ stderrOutput.push(str);
+ };
+
+ // @ts-expect-error
+ process.stderr.write = (str: string) => {
+ // originalStderr(str);
+ stderrOutput.push(str);
+ };
+});
+
+afterEach(() => {
+ process.stdout.write = originalStdout;
+ process.stderr.write = originalStderr;
+ console.log = originalConsoleLog;
+ console.error = originalConsoleError;
+});