44 getDeploymentImageRef ,
55 getEcrAuthToken ,
66 parseEcrRegistryDomain ,
7+ parseRegistryTags ,
78} from "../app/v3/getDeploymentImageRef.server" ;
89import { DeleteRepositoryCommand } from "@aws-sdk/client-ecr" ;
910
@@ -12,6 +13,7 @@ describe.skipIf(process.env.RUN_REGISTRY_TESTS !== "1")("getDeploymentImageRef",
1213 process . env . DEPLOY_REGISTRY_HOST || "123456789012.dkr.ecr.us-east-1.amazonaws.com" ;
1314 const testNamespace = process . env . DEPLOY_REGISTRY_NAMESPACE || "test-namespace" ;
1415 const testProjectRef = "proj_test_" + Math . random ( ) . toString ( 36 ) . substring ( 7 ) ;
16+ const testProjectRef2 = testProjectRef + "_2" ;
1517
1618 const registryTags = process . env . DEPLOY_REGISTRY_ECR_TAGS || "test=test,test2=test2" ;
1719 const roleArn = process . env . DEPLOY_REGISTRY_ECR_ASSUME_ROLE_ARN ;
@@ -30,13 +32,23 @@ describe.skipIf(process.env.RUN_REGISTRY_TESTS !== "1")("getDeploymentImageRef",
3032 try {
3133 const { region, accountId } = parseEcrRegistryDomain ( testHost ) ;
3234 const ecr = await createEcrClient ( { region, assumeRole } ) ;
33- await ecr . send (
34- new DeleteRepositoryCommand ( {
35- repositoryName : `${ testNamespace } /${ testProjectRef } ` ,
36- registryId : accountId ,
37- force : true ,
38- } )
39- ) ;
35+
36+ await Promise . all ( [
37+ ecr . send (
38+ new DeleteRepositoryCommand ( {
39+ repositoryName : `${ testNamespace } /${ testProjectRef } ` ,
40+ registryId : accountId ,
41+ force : true ,
42+ } )
43+ ) ,
44+ ecr . send (
45+ new DeleteRepositoryCommand ( {
46+ repositoryName : `${ testNamespace } /${ testProjectRef2 } ` ,
47+ registryId : accountId ,
48+ force : true ,
49+ } )
50+ ) ,
51+ ] ) ;
4052 } catch ( error ) {
4153 console . warn ( "Failed to delete test repository:" , error ) ;
4254 }
@@ -60,20 +72,37 @@ describe.skipIf(process.env.RUN_REGISTRY_TESTS !== "1")("getDeploymentImageRef",
6072 } ) ;
6173
6274 it ( "should create ECR repository and return correct image ref" , async ( ) => {
63- const imageRef = await getDeploymentImageRef ( {
75+ const imageRef1 = await getDeploymentImageRef ( {
6476 host : testHost ,
6577 namespace : testNamespace ,
66- projectRef : testProjectRef ,
78+ projectRef : testProjectRef2 ,
6779 nextVersion : "20250630.1" ,
6880 environmentSlug : "test" ,
6981 registryTags,
7082 assumeRole,
7183 } ) ;
7284
73- expect ( imageRef . imageRef ) . toBe (
74- `${ testHost } /${ testNamespace } /${ testProjectRef } :20250630.1.test`
85+ expect ( imageRef1 . imageRef ) . toBe (
86+ `${ testHost } /${ testNamespace } /${ testProjectRef2 } :20250630.1.test`
7587 ) ;
76- expect ( imageRef . isEcr ) . toBe ( true ) ;
88+ expect ( imageRef1 . isEcr ) . toBe ( true ) ;
89+ expect ( imageRef1 . repoCreated ) . toBe ( true ) ;
90+
91+ const imageRef2 = await getDeploymentImageRef ( {
92+ host : testHost ,
93+ namespace : testNamespace ,
94+ projectRef : testProjectRef2 ,
95+ nextVersion : "20250630.2" ,
96+ environmentSlug : "test" ,
97+ registryTags,
98+ assumeRole,
99+ } ) ;
100+
101+ expect ( imageRef2 . imageRef ) . toBe (
102+ `${ testHost } /${ testNamespace } /${ testProjectRef2 } :20250630.2.test`
103+ ) ;
104+ expect ( imageRef2 . isEcr ) . toBe ( true ) ;
105+ expect ( imageRef2 . repoCreated ) . toBe ( false ) ;
77106 } ) ;
78107
79108 it ( "should reuse existing ECR repository" , async ( ) => {
0 commit comments