Skip to content

Commit edf742e

Browse files
committed
Test fixups
1 parent 01d4e59 commit edf742e

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

packages/wrangler/src/__tests__/cloudchamber/apply.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
Application,
1818
CreateApplicationRequest,
1919
ModifyApplicationRequestBody,
20-
UserDeploymentConfiguration,
2120
} from "@cloudflare/containers-shared";
2221

2322
function mockGetApplications(applications: Application[]) {
@@ -34,15 +33,15 @@ function mockGetApplications(applications: Application[]) {
3433

3534
function mockCreateApplication(
3635
response?: Partial<Application>,
37-
expected?: Partial<UserDeploymentConfiguration>
36+
expected?: Partial<CreateApplicationRequest>
3837
) {
3938
msw.use(
4039
http.post(
4140
"*/applications",
4241
async ({ request }) => {
43-
const body = (await request.json()) as Application;
42+
const body = (await request.json()) as CreateApplicationRequest;
4443
if (expected !== undefined) {
45-
expect(body.configuration.image).toEqual(expected.image);
44+
expect(body).toMatchObject(expected);
4645
}
4746
expect(body).toHaveProperty("instances");
4847
return HttpResponse.json(response);
@@ -1881,7 +1880,9 @@ describe("cloudchamber apply", () => {
18811880
mockCreateApplication(
18821881
{ id: "abc" },
18831882
{
1884-
image: `${registry}/some-account-id/hello:1.0`,
1883+
configuration: {
1884+
image: `${registry}/some-account-id/hello:1.0`,
1885+
},
18851886
}
18861887
);
18871888

packages/wrangler/src/__tests__/cloudchamber/build.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe("buildAndMaybePush", () => {
6262
buildCmd: [
6363
"build",
6464
"-t",
65-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
65+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
6666
"--platform",
6767
"linux/amd64",
6868
"--provenance=false",
@@ -73,13 +73,13 @@ describe("buildAndMaybePush", () => {
7373
dockerfile,
7474
});
7575
expect(dockerImageInspect).toHaveBeenCalledWith("/custom/docker/path", {
76-
imageTag: `${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
76+
imageTag: `${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
7777
formatString:
7878
"{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}",
7979
});
8080
expect(runDockerCmd).toHaveBeenCalledWith("/custom/docker/path", [
8181
"push",
82-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
82+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
8383
]);
8484
expect(dockerLoginManagedRegistry).toHaveBeenCalledWith(
8585
"/custom/docker/path"
@@ -94,7 +94,7 @@ describe("buildAndMaybePush", () => {
9494
buildCmd: [
9595
"build",
9696
"-t",
97-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
97+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
9898
"--platform",
9999
"linux/amd64",
100100
"--provenance=false",
@@ -107,11 +107,11 @@ describe("buildAndMaybePush", () => {
107107
expect(runDockerCmd).toHaveBeenCalledTimes(1);
108108
expect(runDockerCmd).toHaveBeenCalledWith("docker", [
109109
"push",
110-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
110+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
111111
]);
112112
expect(dockerImageInspect).toHaveBeenCalledOnce();
113113
expect(dockerImageInspect).toHaveBeenCalledWith("docker", {
114-
imageTag: `${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
114+
imageTag: `${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
115115
formatString:
116116
"{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}",
117117
});
@@ -121,7 +121,7 @@ describe("buildAndMaybePush", () => {
121121
it("should be able to build image and not push if it already exists in remote", async () => {
122122
vi.mocked(runDockerCmd).mockResolvedValueOnce();
123123
vi.mocked(dockerImageInspect).mockResolvedValue(
124-
'53387881 2 ["registry.cloudflare.com/test_account_id/test-app@sha256:three"]'
124+
'53387881 2 ["registry.cloudflare.com/some-account-id/test-app@sha256:three"]'
125125
);
126126
await runWrangler(
127127
"containers build ./container-context -t test-app:tag -p"
@@ -130,7 +130,7 @@ describe("buildAndMaybePush", () => {
130130
buildCmd: [
131131
"build",
132132
"-t",
133-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
133+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
134134
"--platform",
135135
"linux/amd64",
136136
"--provenance=false",
@@ -147,18 +147,18 @@ describe("buildAndMaybePush", () => {
147147
[
148148
"manifest",
149149
"inspect",
150-
`${getCloudflareContainerRegistry()}/test_account_id/test-app@sha256:three`,
150+
`${getCloudflareContainerRegistry()}/some-account-id/test-app@sha256:three`,
151151
],
152152
"ignore"
153153
);
154154
expect(runDockerCmd).toHaveBeenNthCalledWith(2, "docker", [
155155
"image",
156156
"rm",
157-
`${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
157+
`${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
158158
]);
159159
expect(dockerImageInspect).toHaveBeenCalledOnce();
160160
expect(dockerImageInspect).toHaveBeenCalledWith("docker", {
161-
imageTag: `${getCloudflareContainerRegistry()}/test_account_id/test-app:tag`,
161+
imageTag: `${getCloudflareContainerRegistry()}/some-account-id/test-app:tag`,
162162
formatString:
163163
"{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}",
164164
});
@@ -172,7 +172,7 @@ describe("buildAndMaybePush", () => {
172172
buildCmd: [
173173
"build",
174174
"-t",
175-
`${getCloudflareContainerRegistry()}/test_account_id/test-app`,
175+
`${getCloudflareContainerRegistry()}/some-account-id/test-app`,
176176
"--platform",
177177
"linux/amd64",
178178
"--provenance=false",
@@ -194,7 +194,7 @@ describe("buildAndMaybePush", () => {
194194
buildCmd: [
195195
"build",
196196
"-t",
197-
`${getCloudflareContainerRegistry()}/test_account_id/test-app`,
197+
`${getCloudflareContainerRegistry()}/some-account-id/test-app`,
198198
"--platform",
199199
"linux/amd64",
200200
"--provenance=false",

packages/wrangler/src/__tests__/cloudchamber/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export function mockAccount() {
2121
const spy = vi.spyOn(user, "getScopes");
2222
spy.mockImplementationOnce(() => ["cloudchamber:write", "containers:write"]);
2323

24+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
25+
2426
msw.use(
2527
http.get(
2628
"*/me",
2729
async () => {
2830
return HttpResponse.json({
29-
external_account_id: "test_account_id",
31+
external_account_id: accountId,
3032
limits: {
3133
disk_mb_per_deployment: 2000,
3234
},
@@ -41,6 +43,8 @@ export function mockAccountV4(scopes: user.Scope[] = ["containers:write"]) {
4143
const spy = vi.spyOn(user, "getScopes");
4244
spy.mockImplementationOnce(() => scopes);
4345

46+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
47+
4448
msw.use(
4549
http.get(
4650
"*/me",
@@ -49,7 +53,7 @@ export function mockAccountV4(scopes: user.Scope[] = ["containers:write"]) {
4953
{
5054
success: true,
5155
result: {
52-
external_account_id: "test_account_id",
56+
external_account_id: accountId,
5357
limits: {
5458
disk_mb_per_deployment: 2000,
5559
},

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8784,7 +8784,7 @@ addEventListener('fetch', event => {});`
87848784
"build",
87858785
"-t",
87868786
getCloudflareContainerRegistry() +
8787-
"/test_account_id/my-container:Galaxy",
8787+
"/some-account-id/my-container:Galaxy",
87888788
"--platform",
87898789
"linux/amd64",
87908790
"--provenance=false",
@@ -8823,7 +8823,7 @@ addEventListener('fetch', event => {});`
88238823
expect(args).toEqual([
88248824
"image",
88258825
"inspect",
8826-
`${getCloudflareContainerRegistry()}/test_account_id/my-container:Galaxy`,
8826+
`${getCloudflareContainerRegistry()}/some-account-id/my-container:Galaxy`,
88278827
"--format",
88288828
"{{ .Size }} {{ len .RootFS.Layers }} {{json .RepoDigests}}",
88298829
]);
@@ -8847,7 +8847,7 @@ addEventListener('fetch', event => {});`
88478847
setImmediate(() => {
88488848
stdout.emit(
88498849
"data",
8850-
`123456 4 ["${getCloudflareContainerRegistry()}/test_account_id/my-container@sha256:three"]`
8850+
`123456 4 ["${getCloudflareContainerRegistry()}/some-account-id/my-container@sha256:three"]`
88518851
);
88528852
});
88538853

@@ -8888,7 +8888,7 @@ addEventListener('fetch', event => {});`
88888888
expect(args).toEqual([
88898889
"manifest",
88908890
"inspect",
8891-
`${getCloudflareContainerRegistry()}/test_account_id/my-container@three`,
8891+
`${getCloudflareContainerRegistry()}/some-account-id/my-container@three`,
88928892
]);
88938893
const readable = new Writable({
88948894
write() {},
@@ -8917,7 +8917,7 @@ addEventListener('fetch', event => {});`
89178917
expect(cmd).toBe("/usr/bin/docker");
89188918
expect(args).toEqual([
89198919
"push",
8920-
`${getCloudflareContainerRegistry()}/test_account_id/my-container:Galaxy`,
8920+
`${getCloudflareContainerRegistry()}/some-account-id/my-container:Galaxy`,
89218921
]);
89228922
return defaultChildProcess();
89238923
});
@@ -8977,7 +8977,7 @@ addEventListener('fetch', event => {});`
89778977
return HttpResponse.json({
89788978
success: true,
89798979
result: {
8980-
account_id: "test_account_id",
8980+
account_id: "some-account-id",
89818981
registry_host: getCloudflareContainerRegistry(),
89828982
username: "v1",
89838983
password: "mockpassword",
@@ -8998,7 +8998,7 @@ addEventListener('fetch', event => {});`
89988998
configuration: {
89998999
image:
90009000
getCloudflareContainerRegistry() +
9001-
"/test_account_id/my-container:Galaxy",
9001+
"/some-account-id/my-container:Galaxy",
90029002
},
90039003
});
90049004

@@ -9035,7 +9035,7 @@ addEventListener('fetch', event => {});`
90359035
90369036
Uploaded test-name (TIMINGS)
90379037
Building image my-container:Galaxy
9038-
Image does not exist remotely, pushing: registry.cloudflare.com/test_account_id/my-container:Galaxy
9038+
Image does not exist remotely, pushing: registry.cloudflare.com/some-account-id/my-container:Galaxy
90399039
Deployed test-name triggers (TIMINGS)
90409040
https://test-name.test-sub-domain.workers.dev
90419041
Current Version ID: Galaxy-Class"

0 commit comments

Comments
 (0)