Skip to content

🎥 Make videos programmatically with React

fix tests

Jonny Burger6aea5da55ec0
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsx
index 0b8534878b..058169e8f3 100644
--- a/packages/cli/src/index.tsx
+++ b/packages/cli/src/index.tsx
@@ -70,4 +70,5 @@ export const CliInternals = {
initializeRenderCli,
BooleanFlags,
quietFlagProvided,
+ parsedCli,
};
diff --git a/packages/lambda/src/api/__mocks__/create-function.ts b/packages/lambda/src/api/__mocks__/create-function.ts
index 19d57e22ae..66f6906764 100644
--- a/packages/lambda/src/api/__mocks__/create-function.ts
+++ b/packages/lambda/src/api/__mocks__/create-function.ts
@@ -1,17 +1,20 @@
-import {CURRENT_VERSION} from '../../defaults';
+import {CURRENT_VERSION, DEFAULT_MEMORY_SIZE} from '../../defaults';
import {createFunction as original} from '../create-function';
import {addFunction} from '../mock-functions';
export const createFunction: typeof original = async (input) => {
- addFunction(
- {
- functionName: input.functionName,
- memorySizeInMb: 1024,
- timeoutInSeconds: input.timeoutInSeconds,
- version: CURRENT_VERSION,
- },
- input.region
- );
+ if (!input.alreadyCreated) {
+ addFunction(
+ {
+ functionName: input.functionName,
+ memorySizeInMb: DEFAULT_MEMORY_SIZE,
+ timeoutInSeconds: input.timeoutInSeconds,
+ version: CURRENT_VERSION,
+ },
+ input.region
+ );
+ }
+
return Promise.resolve({
FunctionName: input.functionName,
});
diff --git a/tests/lambda/cli.test.ts b/tests/lambda/cli.test.ts
index 966f2fac1a..6057a02835 100644
--- a/tests/lambda/cli.test.ts
+++ b/tests/lambda/cli.test.ts
@@ -1,3 +1,9 @@
+import {
+ CURRENT_VERSION,
+ DEFAULT_MEMORY_SIZE,
+ DEFAULT_TIMEOUT,
+} from "@remotion/lambda/dist/defaults";
+import { CliInternals } from "../../packages/lambda/node_modules/@remotion/cli/dist";
import { parsedLambdaCli } from "../../packages/lambda/src/cli/args";
import { LambdaInternals } from "../../packages/lambda/src/index";
import { getProcessStdErrOutput, getProcessWriteOutput } from "./console-hooks";
@@ -5,7 +11,7 @@ import { getProcessStdErrOutput, getProcessWriteOutput } from "./console-hooks";
test("Deploy function", async () => {
await LambdaInternals.executeCommand(["functions", "deploy"]);
expect(getProcessWriteOutput()).toContain(
- "Deployed as remotion-render-abcdef\n"
+ `Deployed as remotion-render-${CURRENT_VERSION}-${DEFAULT_MEMORY_SIZE}mb-${DEFAULT_TIMEOUT}sec\n`
);
});
@@ -14,24 +20,18 @@ test("Deploy function and list it", async () => {
await LambdaInternals.executeCommand(["functions", "ls"]);
expect(getProcessWriteOutput()).toContain("Getting functions...");
expect(getProcessWriteOutput()).toContain("Memory (MB)");
- expect(getProcessWriteOutput()).toMatch(
- /remotion-render-abcdef\s+(.*)\s+1024\s+120/g
- );
+ 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 expect(() =>
- LambdaInternals.executeCommand(["functions", "deploy"])
- ).rejects.toThrow(/Exited process with code 1/);
+ await LambdaInternals.executeCommand(["functions", "deploy"]);
- expect(getProcessStdErrOutput()).toMatch(
- /Error: Already found a function \(remotion-render-abcdef\) with version (.*) deployed in region us-east-1/
- );
+ expect(getProcessWriteOutput()).toMatch(/Already exists as remotion-render/);
});
test('If no functions are there and is quiet, should return "()"', async () => {
- parsedLambdaCli.q = true;
+ CliInternals.parsedCli.q = true;
await LambdaInternals.executeCommand(["functions", "ls"]);
expect(getProcessWriteOutput()).toBe("()");
});