-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Versions deployments commands (#5224)
- Loading branch information
Showing
18 changed files
with
993 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": minor | ||
--- | ||
|
||
feature: Implement `wrangler deployments list` and `wrangler deployments status` behind `--experimental-gradual-rollouts` flag. |
21 changes: 21 additions & 0 deletions
21
packages/wrangler/src/__tests__/helpers/collect-cli-output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { stderr, stdout } from "@cloudflare/cli/streams"; | ||
|
||
export function collectCLIOutput() { | ||
const std = { out: "", err: "" }; | ||
const onStdOutData = (chunk: Buffer) => (std.out += chunk.toString()); | ||
const onStdErrData = (chunk: Buffer) => (std.err += chunk.toString()); | ||
|
||
beforeEach(() => { | ||
stdout.on("data", onStdOutData); | ||
stderr.on("data", onStdErrData); | ||
}); | ||
|
||
afterEach(() => { | ||
stdout.off("data", onStdOutData); | ||
stderr.off("data", onStdErrData); | ||
std.out = ""; | ||
std.err = ""; | ||
}); | ||
|
||
return std; | ||
} |
176 changes: 176 additions & 0 deletions
176
packages/wrangler/src/__tests__/versions/deployments/deployments.list.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
import { normalizeOutput } from "../../../../e2e/helpers/normalize"; | ||
import { collectCLIOutput } from "../../helpers/collect-cli-output"; | ||
import { mockAccountId, mockApiToken } from "../../helpers/mock-account-id"; | ||
import { msw, mswGetVersion, mswListNewDeployments } from "../../helpers/msw"; | ||
import { runInTempDir } from "../../helpers/run-in-tmp"; | ||
import { runWrangler } from "../../helpers/run-wrangler"; | ||
import writeWranglerToml from "../../helpers/write-wrangler-toml"; | ||
|
||
describe("deployments list", () => { | ||
mockAccountId(); | ||
mockApiToken(); | ||
runInTempDir(); | ||
const std = collectCLIOutput(); | ||
|
||
beforeEach(() => { | ||
msw.use(mswListNewDeployments, mswGetVersion); | ||
}); | ||
|
||
describe("without wrangler.toml", () => { | ||
test("fails with no args", async () => { | ||
const result = runWrangler( | ||
"deployments list --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).rejects.toMatchInlineSnapshot( | ||
`[Error: You need to provide a name of your worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = "<name>"\`]` | ||
); | ||
|
||
expect(std.out).toMatchInlineSnapshot(`""`); | ||
|
||
expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`); | ||
}); | ||
|
||
test("prints deployments to stdout", async () => { | ||
const result = runWrangler( | ||
"deployments list --name test-name --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).resolves.toBeUndefined(); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"Created: 2021-01-04T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Rollback | ||
Message: - | ||
Version(s): (10%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(90%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-01-01T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Upload | ||
Message: - | ||
Version(s): (20%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(80%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-02-02T00:00:00.000Z | ||
Author: Kathryn-Janeway@federation.org | ||
Source: Rollback | ||
Message: Rolled back for this version | ||
Version(s): (30%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(70%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-02-03T00:00:00.000Z | ||
Author: Kathryn-Janeway@federation.org | ||
Source: Wrangler 🤠 | ||
Message: - | ||
Version(s): (40%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(60%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
" | ||
`); | ||
|
||
expect(std.err).toMatchInlineSnapshot(`""`); | ||
}); | ||
}); | ||
|
||
describe("with wrangler.toml", () => { | ||
beforeEach(writeWranglerToml); | ||
|
||
test("prints deployments to stdout", async () => { | ||
const result = runWrangler( | ||
"deployments list --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).resolves.toBeUndefined(); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"Created: 2021-01-04T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Rollback | ||
Message: - | ||
Version(s): (10%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(90%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-01-01T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Upload | ||
Message: - | ||
Version(s): (20%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(80%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-02-02T00:00:00.000Z | ||
Author: Kathryn-Janeway@federation.org | ||
Source: Rollback | ||
Message: Rolled back for this version | ||
Version(s): (30%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(70%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
Created: 2021-02-03T00:00:00.000Z | ||
Author: Kathryn-Janeway@federation.org | ||
Source: Wrangler 🤠 | ||
Message: - | ||
Version(s): (40%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(60%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
" | ||
`); | ||
|
||
expect(std.err).toMatchInlineSnapshot(`""`); | ||
}); | ||
}); | ||
}); |
92 changes: 92 additions & 0 deletions
92
packages/wrangler/src/__tests__/versions/deployments/deployments.status.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { normalizeOutput } from "../../../../e2e/helpers/normalize"; | ||
import { collectCLIOutput } from "../../helpers/collect-cli-output"; | ||
import { mockAccountId, mockApiToken } from "../../helpers/mock-account-id"; | ||
import { msw, mswGetVersion, mswListNewDeployments } from "../../helpers/msw"; | ||
import { runInTempDir } from "../../helpers/run-in-tmp"; | ||
import { runWrangler } from "../../helpers/run-wrangler"; | ||
import writeWranglerToml from "../../helpers/write-wrangler-toml"; | ||
|
||
describe("deployments list", () => { | ||
mockAccountId(); | ||
mockApiToken(); | ||
runInTempDir(); | ||
const std = collectCLIOutput(); | ||
|
||
beforeEach(() => { | ||
msw.use(mswListNewDeployments, mswGetVersion); | ||
}); | ||
|
||
describe("without wrangler.toml", () => { | ||
test("fails with no args", async () => { | ||
const result = runWrangler( | ||
"deployments status --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).rejects.toMatchInlineSnapshot( | ||
`[Error: You need to provide a name of your worker. Either pass it as a cli arg with \`--name <name>\` or in your config file as \`name = "<name>"\`]` | ||
); | ||
|
||
expect(std.out).toMatchInlineSnapshot(`""`); | ||
|
||
expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`); | ||
}); | ||
|
||
test("prints latest deployment to stdout", async () => { | ||
const result = runWrangler( | ||
"deployments status --name test-name --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).resolves.toBeUndefined(); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"Created: 2021-01-04T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Rollback | ||
Message: - | ||
Version(s): (10%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(90%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
" | ||
`); | ||
|
||
expect(std.err).toMatchInlineSnapshot(`""`); | ||
}); | ||
}); | ||
|
||
describe("with wrangler.toml", () => { | ||
beforeEach(writeWranglerToml); | ||
|
||
test("prints latest deployment to stdout", async () => { | ||
const result = runWrangler( | ||
"deployments status --experimental-gradual-rollouts" | ||
); | ||
|
||
await expect(result).resolves.toBeUndefined(); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"Created: 2021-01-04T00:00:00.000Z | ||
Author: Jean-Luc-Picard@federation.org | ||
Source: Rollback | ||
Message: - | ||
Version(s): (10%) 10000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
(90%) 20000000-0000-0000-0000-000000000000 | ||
Created: 2021-01-01T00:00:00.000Z | ||
Tag: - | ||
Message: - | ||
" | ||
`); | ||
|
||
expect(std.err).toMatchInlineSnapshot(`""`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.