Skip to content

Commit a721b30

Browse files
committed
replace regexps in tests
1 parent 0a17676 commit a721b30

File tree

1 file changed

+14
-41
lines changed

1 file changed

+14
-41
lines changed

apps/webapp/test/getDeploymentImageRef.test.ts

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
} from "../app/v3/getDeploymentImageRef.server";
99
import { DeleteRepositoryCommand } from "@aws-sdk/client-ecr";
1010

11-
const escapeHostForRegex = (host: string) => host.replace(/\./g, "\\.");
12-
1311
describe("getDeploymentImageRef", () => {
1412
const testHost =
1513
process.env.DEPLOY_REGISTRY_HOST || "123456789012.dkr.ecr.us-east-1.amazonaws.com";
@@ -74,12 +72,8 @@ describe("getDeploymentImageRef", () => {
7472
});
7573

7674
// Check the image ref structure and that it contains expected parts
77-
expect(imageRef.imageRef).toMatch(
78-
new RegExp(
79-
`^${escapeHostForRegex(
80-
"registry.example.com"
81-
)}/${testNamespace}/${testProjectRef}:20250630\\.1\\.development\\.test1234$`
82-
)
75+
expect(imageRef.imageRef).toBe(
76+
`registry.example.com/${testNamespace}/${testProjectRef}:20250630.1.development.test1234`
8377
);
8478
expect(imageRef.isEcr).toBe(false);
8579
});
@@ -103,12 +97,8 @@ describe("getDeploymentImageRef", () => {
10397
deploymentShortCode: "test1234",
10498
});
10599

106-
expect(imageRef1.imageRef).toMatch(
107-
new RegExp(
108-
`^${escapeHostForRegex(
109-
testHost
110-
)}/${testNamespace}/${testProjectRef2}:20250630\\.1\\.development\\.test1234$`
111-
)
100+
expect(imageRef1.imageRef).toBe(
101+
`${testHost}/${testNamespace}/${testProjectRef2}:20250630.1.development.test1234`
112102
);
113103
expect(imageRef1.isEcr).toBe(true);
114104
expect(imageRef1.repoCreated).toBe(true);
@@ -129,12 +119,8 @@ describe("getDeploymentImageRef", () => {
129119
deploymentShortCode: "test1234",
130120
});
131121

132-
expect(imageRef2.imageRef).toMatch(
133-
new RegExp(
134-
`^${escapeHostForRegex(
135-
testHost
136-
)}/${testNamespace}/${testProjectRef2}:20250630\\.2\\.development\\.test1234$`
137-
)
122+
expect(imageRef2.imageRef).toBe(
123+
`${testHost}/${testNamespace}/${testProjectRef2}:20250630.2.development.test1234`
138124
);
139125
expect(imageRef2.isEcr).toBe(true);
140126
expect(imageRef2.repoCreated).toBe(false);
@@ -159,12 +145,8 @@ describe("getDeploymentImageRef", () => {
159145
deploymentShortCode: "test1234",
160146
});
161147

162-
expect(imageRef.imageRef).toMatch(
163-
new RegExp(
164-
`^${escapeHostForRegex(
165-
testHost
166-
)}/${testNamespace}/${testProjectRef}:20250630\\.2\\.production\\.test1234$`
167-
)
148+
expect(imageRef.imageRef).toBe(
149+
`${testHost}/${testNamespace}/${testProjectRef}:20250630.2.production.test1234`
168150
);
169151
expect(imageRef.isEcr).toBe(true);
170152
});
@@ -206,20 +188,12 @@ describe("getDeploymentImageRef", () => {
206188
deploymentShortCode: "test4321",
207189
});
208190

209-
// Even with the same environment type and version, the image refs should be different due to random suffix
210-
expect(firstImageRef.imageRef).toMatch(
211-
new RegExp(
212-
`^${escapeHostForRegex(
213-
"registry.example.com"
214-
)}/${testNamespace}/${testProjectRef}:${sameVersion}\\.preview\\.test1234$`
215-
)
191+
// Even with the same environment type and version, the image refs should be different due to deployment short codes
192+
expect(firstImageRef.imageRef).toBe(
193+
`registry.example.com/${testNamespace}/${testProjectRef}:${sameVersion}.preview.test1234`
216194
);
217-
expect(secondImageRef.imageRef).toMatch(
218-
new RegExp(
219-
`^${escapeHostForRegex(
220-
"registry.example.com"
221-
)}/${testNamespace}/${testProjectRef}:${sameVersion}\\.preview\\.test4321$`
222-
)
195+
expect(secondImageRef.imageRef).toBe(
196+
`registry.example.com/${testNamespace}/${testProjectRef}:${sameVersion}.preview.test4321`
223197
);
224198
expect(firstImageRef.imageRef).not.toBe(secondImageRef.imageRef);
225199
});
@@ -250,8 +224,7 @@ describe.skipIf(process.env.RUN_ECR_TESTS !== "1")("getEcrAuthToken", () => {
250224
expect(auth.password.length).toBeGreaterThan(0);
251225

252226
// Verify the token format (should be a base64-encoded string)
253-
const base64Regex = /^[A-Za-z0-9+/=]+$/;
254-
expect(base64Regex.test(auth.password)).toBe(true);
227+
expect(auth.password).toMatch(/^[A-Za-z0-9+/=]+$/);
255228
});
256229

257230
it("should throw error for invalid region", async () => {

0 commit comments

Comments
 (0)