🎥 Make videos programmatically with React
add test cases
Alex Fernandezcd56e6cd2b17
diff --git a/packages/cloudrun/src/api/test/running-in-what-server.test.ts b/packages/cloudrun/src/api/test/running-in-what-server.test.tsnew file mode 100644index 0000000000..33568da29a--- /dev/null+++ b/packages/cloudrun/src/api/test/running-in-what-server.test.ts@@ -0,0 +1,38 @@+import {beforeEach, expect, test} from 'vitest';+import {+ getProjectId,+ isInCloudTask,+} from '../../functions/helpers/is-in-cloud-task';++beforeEach(() => {+ delete process.env.GCLOUD_PROJECT;+ delete process.env.REMOTION_GCP_PROJECT_ID;+ delete process.env.K_CONFIGURATION;+});++test('is running in cloud tasks = true', () => {+ process.env.GCLOUD_PROJECT = 'remotion-test-cloudtask';+ process.env.K_CONFIGURATION = 'config';+ const isInCloud = isInCloudTask();++ expect(isInCloud).toBe(true);+});++test('is running in cloud tasks = false', () => {+ process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test-cloudtask';+ const isInCloud = isInCloudTask();+ expect(isInCloud).toBe(false);+});++test('which project Id = remotion-test', () => {+ process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test';+ const projectId = getProjectId();+ expect(projectId).toBe('remotion-test');+});++test('which project Id = remotion-test-cloudtask', () => {+ process.env.GCLOUD_PROJECT = 'remotion-test-cloudtask';+ process.env.K_CONFIGURATION = 'config';+ const projectId = getProjectId();+ expect(projectId).toBe('remotion-test-cloudtask');+});diff --git a/packages/cloudrun/src/api/test/service-names.test.ts b/packages/cloudrun/src/api/test/service-names.test.tsindex a0b9924d87..ee0fa0c827 100644--- a/packages/cloudrun/src/api/test/service-names.test.ts+++ b/packages/cloudrun/src/api/test/service-names.test.ts@@ -7,9 +7,9 @@ import {speculateServiceName} from '../speculate-service-name';const dashedVersion = VERSION.replace(/\./g, '-');const region: GcpRegion = 'asia-east1';-process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test-project';-test('Parse service names', () => {+ process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test-project';+const shortServiceName = speculateServiceName({cpuLimit: '8.0',memoryLimit: '100000k',diff --git a/packages/cloudrun/src/functions/helpers/is-in-cloud-task.ts b/packages/cloudrun/src/functions/helpers/is-in-cloud-task.tsindex 7e028294bf..9c4e6d735c 100644--- a/packages/cloudrun/src/functions/helpers/is-in-cloud-task.ts+++ b/packages/cloudrun/src/functions/helpers/is-in-cloud-task.ts@@ -1,9 +1,10 @@-export const isInCloudTask = () => {- return (- process.env.K_CONFIGURATION &&- process.env.GCLOUD_PROJECT &&- !process.env.REMOTION_GCP_PROJECT_ID- );+export const isInCloudTask = (): boolean => {+ if (process.env.REMOTION_GCP_PROJECT_ID) return false;+ if (process.env.K_CONFIGURATION && process.env.GCLOUD_PROJECT) {+ return true;+ }++ return false;};export const getProjectId = (): string | undefined => {