1
- import { spawn } from "node:child_process" ;
1
+ import { execFileSync , spawn } from "node:child_process" ;
2
2
import * as fs from "node:fs" ;
3
3
import { PassThrough , Writable } from "node:stream" ;
4
4
import {
@@ -111,19 +111,19 @@ describe("wrangler deploy with containers", () => {
111
111
await runWrangler ( "deploy index.js" ) ;
112
112
113
113
expect ( std . out ) . toMatchInlineSnapshot ( `
114
- "Total Upload: xx KiB / gzip: xx KiB
115
- Worker Startup Time: 100 ms
116
- Your Worker has access to the following bindings:
117
- Binding Resource
118
- env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
114
+ "Total Upload: xx KiB / gzip: xx KiB
115
+ Worker Startup Time: 100 ms
116
+ Your Worker has access to the following bindings:
117
+ Binding Resource
118
+ env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
119
119
120
- Uploaded test-name (TIMINGS)
121
- Building image my-container:Galaxy
122
- Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
123
- Deployed test-name triggers (TIMINGS)
124
- https://test-name.test-sub-domain.workers.dev
125
- Current Version ID: Galaxy-Class"
126
- ` ) ;
120
+ Uploaded test-name (TIMINGS)
121
+ Building image my-container:Galaxy
122
+ Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
123
+ Deployed test-name triggers (TIMINGS)
124
+ https://test-name.test-sub-domain.workers.dev
125
+ Current Version ID: Galaxy-Class"
126
+ ` ) ;
127
127
expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
128
128
expect ( std . warn ) . toMatchInlineSnapshot ( `""` ) ;
129
129
expect ( cliStd . stdout ) . toMatchInlineSnapshot ( `
@@ -448,19 +448,19 @@ describe("wrangler deploy with containers", () => {
448
448
await runWrangler ( "deploy --cwd src" ) ;
449
449
450
450
expect ( std . out ) . toMatchInlineSnapshot ( `
451
- "Total Upload: xx KiB / gzip: xx KiB
452
- Worker Startup Time: 100 ms
453
- Your Worker has access to the following bindings:
454
- Binding Resource
455
- env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
456
-
457
- Uploaded test-name (TIMINGS)
458
- Building image my-container:Galaxy
459
- Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
460
- Deployed test-name triggers (TIMINGS)
461
- https://test-name.test-sub-domain.workers.dev
462
- Current Version ID: Galaxy-Class"
463
- ` ) ;
451
+ "Total Upload: xx KiB / gzip: xx KiB
452
+ Worker Startup Time: 100 ms
453
+ Your Worker has access to the following bindings:
454
+ Binding Resource
455
+ env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
456
+
457
+ Uploaded test-name (TIMINGS)
458
+ Building image my-container:Galaxy
459
+ Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
460
+ Deployed test-name triggers (TIMINGS)
461
+ https://test-name.test-sub-domain.workers.dev
462
+ Current Version ID: Galaxy-Class"
463
+ ` ) ;
464
464
expect ( std . err ) . toMatchInlineSnapshot ( `""` ) ;
465
465
expect ( std . warn ) . toMatchInlineSnapshot ( `""` ) ;
466
466
} ) ;
@@ -599,7 +599,7 @@ describe("wrangler deploy with containers", () => {
599
599
│ [containers.constraints]
600
600
│
601
601
│
602
- │ SUCCESS Modified application my-container
602
+ │ SUCCESS Modified application my-container (Application ID: abc)
603
603
│
604
604
╰ Applied changes
605
605
@@ -740,7 +740,7 @@ describe("wrangler deploy with containers", () => {
740
740
│ [containers.constraints]
741
741
│
742
742
│
743
- │ SUCCESS Modified application my-container
743
+ │ SUCCESS Modified application my-container (Application ID: abc)
744
744
│
745
745
╰ Applied changes
746
746
@@ -908,7 +908,7 @@ describe("wrangler deploy with containers", () => {
908
908
│ tier = 1
909
909
│
910
910
│
911
- │ SUCCESS Modified application my-container
911
+ │ SUCCESS Modified application my-container (Application ID: abc)
912
912
│
913
913
╰ Applied changes
914
914
@@ -954,7 +954,7 @@ describe("wrangler deploy with containers", () => {
954
954
│ tier = 1
955
955
│
956
956
│
957
- │ SUCCESS Modified application my-container
957
+ │ SUCCESS Modified application my-container (Application ID: abc)
958
958
│
959
959
╰ Applied changes
960
960
@@ -1012,7 +1012,7 @@ describe("wrangler deploy with containers", () => {
1012
1012
│ tier = 1
1013
1013
│
1014
1014
│
1015
- │ SUCCESS Modified application my-container
1015
+ │ SUCCESS Modified application my-container (Application ID: abc)
1016
1016
│
1017
1017
╰ Applied changes
1018
1018
@@ -1070,7 +1070,7 @@ describe("wrangler deploy with containers", () => {
1070
1070
│ tier = 1
1071
1071
│
1072
1072
│
1073
- │ SUCCESS Modified application my-container
1073
+ │ SUCCESS Modified application my-container (Application ID: abc)
1074
1074
│
1075
1075
╰ Applied changes
1076
1076
@@ -1124,7 +1124,7 @@ describe("wrangler deploy with containers", () => {
1124
1124
│ tier = 1
1125
1125
│
1126
1126
│
1127
- │ SUCCESS Modified application my-container
1127
+ │ SUCCESS Modified application my-container (Application ID: abc)
1128
1128
│
1129
1129
╰ Applied changes
1130
1130
@@ -1183,7 +1183,7 @@ describe("wrangler deploy with containers", () => {
1183
1183
│ tier = 1
1184
1184
│
1185
1185
│
1186
- │ SUCCESS Modified application my-container
1186
+ │ SUCCESS Modified application my-container (Application ID: abc)
1187
1187
│
1188
1188
╰ Applied changes
1189
1189
@@ -1366,7 +1366,6 @@ describe("wrangler deploy with containers dry run", () => {
1366
1366
mockDockerImageInspectDigests ( "my-container" , "worker" )
1367
1367
)
1368
1368
. mockImplementationOnce ( mockDockerLogin ( "mockpassword" ) )
1369
- . mockImplementationOnce ( mockDockerManifestInspect ( "my-container" , true ) )
1370
1369
. mockImplementationOnce ( mockDockerPush ( "my-container" , "worker" ) ) ;
1371
1370
1372
1371
vi . stubEnv ( "WRANGLER_DOCKER_BIN" , "/usr/bin/docker" ) ;
@@ -1412,7 +1411,7 @@ function createDockerMockChain(
1412
1411
mockDockerImageInspectDigests ( containerName , tag ) ,
1413
1412
mockDockerImageInspectSize ( containerName , tag ) ,
1414
1413
mockDockerLogin ( "mockpassword" ) ,
1415
- mockDockerManifestInspect ( "some-account-id/" + containerName , true ) ,
1414
+ // Skip manifest inspect mock - it's not being called due to empty repoDigests
1416
1415
mockDockerTag ( containerName , "some-account-id/" + containerName , tag ) ,
1417
1416
mockDockerPush ( "some-account-id/" + containerName , tag ) ,
1418
1417
mockDockerImageDelete ( "some-account-id/" + containerName , tag ) ,
@@ -1441,8 +1440,17 @@ function setupDockerMocks(
1441
1440
. mockImplementationOnce ( mocks [ 4 ] )
1442
1441
. mockImplementationOnce ( mocks [ 5 ] )
1443
1442
. mockImplementationOnce ( mocks [ 6 ] )
1444
- . mockImplementationOnce ( mocks [ 7 ] )
1445
- . mockImplementationOnce ( mocks [ 8 ] ) ;
1443
+ . mockImplementationOnce ( mocks [ 7 ] ) ;
1444
+ // Default mock for execFileSync to handle docker verification and other calls
1445
+ vi . mocked ( execFileSync ) . mockImplementation (
1446
+ ( _file : string , args ?: readonly string [ ] ) => {
1447
+ // Handle docker info calls (for verification)
1448
+ if ( args && args [ 0 ] === "manifest" ) {
1449
+ return "i promise I am an unsuccessful docker manifest call" ;
1450
+ }
1451
+ return "" ;
1452
+ }
1453
+ ) ;
1446
1454
}
1447
1455
1448
1456
// Common test setup
@@ -1677,7 +1685,7 @@ function mockDockerImageInspectDigests(containerName: string, tag: string) {
1677
1685
"inspect" ,
1678
1686
`${ getCloudflareContainerRegistry ( ) } /${ containerName } :${ tag } ` ,
1679
1687
"--format" ,
1680
- "{{json .RepoDigests}}" ,
1688
+ "{{ json .RepoDigests }} {{ .Id }}" ,
1681
1689
] ) ;
1682
1690
1683
1691
const stdout = new PassThrough ( ) ;
@@ -1697,7 +1705,7 @@ function mockDockerImageInspectDigests(containerName: string, tag: string) {
1697
1705
setImmediate ( ( ) => {
1698
1706
stdout . emit (
1699
1707
"data" ,
1700
- `["${ getCloudflareContainerRegistry ( ) } /${ containerName } @sha256:three"]`
1708
+ `["${ getCloudflareContainerRegistry ( ) } /${ containerName } @sha256:three"] config-sha `
1701
1709
) ;
1702
1710
} ) ;
1703
1711
@@ -1774,36 +1782,6 @@ function mockDockerLogin(expectedPassword: string) {
1774
1782
} ;
1775
1783
}
1776
1784
1777
- function mockDockerManifestInspect ( containerName : string , shouldFail = true ) {
1778
- return ( cmd : string , args : readonly string [ ] ) => {
1779
- expect ( cmd ) . toBe ( "/usr/bin/docker" ) ;
1780
- expect ( args [ 0 ] ) . toBe ( "manifest" ) ;
1781
- expect ( args [ 1 ] ) . toBe ( "inspect" ) ;
1782
- expect ( args [ 2 ] ) . toEqual ( `${ containerName } @three` ) ;
1783
- expect ( args ) . toEqual ( [
1784
- "manifest" ,
1785
- "inspect" ,
1786
- `${ getCloudflareContainerRegistry ( ) } /${ containerName } @three` ,
1787
- ] ) ;
1788
- const readable = new Writable ( {
1789
- write ( ) { } ,
1790
- final ( ) { } ,
1791
- } ) ;
1792
- return {
1793
- stdout : Buffer . from (
1794
- "i promise I am an unsuccessful docker manifest call"
1795
- ) ,
1796
- stdin : readable ,
1797
- on : function ( reason : string , cbPassed : ( code : number ) => unknown ) {
1798
- if ( reason === "close" ) {
1799
- cbPassed ( shouldFail ? 1 : 0 ) ;
1800
- }
1801
- return this ;
1802
- } ,
1803
- } as unknown as ChildProcess ;
1804
- } ;
1805
- }
1806
-
1807
1785
function mockDockerPush ( containerName : string , tag : string ) {
1808
1786
return ( cmd : string , args : readonly string [ ] ) => {
1809
1787
expect ( cmd ) . toBe ( "/usr/bin/docker" ) ;
0 commit comments