-
Notifications
You must be signed in to change notification settings - Fork 7
/
mod_test.ts
107 lines (99 loc) · 3.38 KB
/
mod_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2024 the Deno authors. All rights reserved. MIT license.
import { assertSnapshot } from "@std/testing/snapshot";
import { copy, exists } from "@std/fs";
import { bumpWorkspaces } from "./mod.ts";
import { join } from "@std/path";
import { tryGetDenoConfig } from "./util.ts";
import { assert, assertEquals } from "@std/assert";
// Note: The test cases in this file use git information in the branch `origin/base-branch-for-testing`.
Deno.test("bumpWorkspaces()", async (t) => {
const dir = await Deno.makeTempDir();
await copy("testdata/basic", dir, { overwrite: true });
await bumpWorkspaces({
dryRun: "git",
githubRepo: "denoland/deno_std",
githubToken: "1234567890",
base: "origin/base-branch-for-testing",
start: "start-tag-for-testing",
root: dir,
});
const releaseNote = await Deno.readTextFile(join(dir, "Releases.md"));
await assertSnapshot(
t,
releaseNote.replace(/^### \d+\.\d+\.\d+/, "### YYYY.MM.DD"),
);
let _, config;
[_, config] = await tryGetDenoConfig(dir);
assertEquals(config, {
imports: {
"@scope/foo": "jsr:@scope/foo@^2.0.0",
"@scope/foo/": "jsr:@scope/foo@^2.0.0/",
"@scope/bar": "jsr:@scope/bar@^2.3.5",
"@scope/bar/": "jsr:@scope/bar@^2.3.5/",
"@scope/baz": "jsr:@scope/baz@^0.2.4",
"@scope/baz/": "jsr:@scope/baz@^0.2.4/",
"@scope/qux": "jsr:@scope/qux@^0.3.5",
"@scope/qux/": "jsr:@scope/qux@^0.3.5/",
"@scope/quux": "jsr:@scope/quux@^0.1.0",
"@scope/quux/": "jsr:@scope/quux@^0.1.0/",
},
workspace: ["./foo", "./bar", "./baz", "./qux", "./quux"],
});
[_, config] = await tryGetDenoConfig(join(dir, "foo"));
assertEquals(config, {
name: "@scope/foo",
version: "2.0.0",
});
[_, config] = await tryGetDenoConfig(join(dir, "bar"));
assertEquals(config, {
name: "@scope/bar",
version: "2.3.5",
});
[_, config] = await tryGetDenoConfig(join(dir, "baz"));
assertEquals(config, {
name: "@scope/baz",
version: "0.2.4",
});
[_, config] = await tryGetDenoConfig(join(dir, "qux"));
assertEquals(config, {
name: "@scope/qux",
version: "0.3.5",
});
[_, config] = await tryGetDenoConfig(join(dir, "quux"));
assertEquals(config, {
name: "@scope/quux",
version: "0.1.0",
});
});
Deno.test(
"bumpWorkspaces() doesn't write things when dry run specified",
async () => {
const dir = await Deno.makeTempDir();
await copy("testdata/basic", dir, { overwrite: true });
await bumpWorkspaces({
dryRun: true,
githubRepo: "denoland/deno_std",
githubToken: "1234567890",
base: "origin/base-branch-for-testing",
start: "start-tag-for-testing",
root: dir,
});
assert(!(await exists(join(dir, "Releases.md"))));
const [_, config] = await tryGetDenoConfig(dir);
assertEquals(config, {
imports: {
"@scope/foo": "jsr:@scope/foo@^1.2.3",
"@scope/foo/": "jsr:@scope/foo@^1.2.3/",
"@scope/bar": "jsr:@scope/bar@^2.3.4",
"@scope/bar/": "jsr:@scope/bar@^2.3.4/",
"@scope/baz": "jsr:@scope/baz@^0.2.3",
"@scope/baz/": "jsr:@scope/baz@^0.2.3/",
"@scope/qux": "jsr:@scope/qux@^0.3.4",
"@scope/qux/": "jsr:@scope/qux@^0.3.4/",
"@scope/quux": "jsr:@scope/quux@^0.0.0",
"@scope/quux/": "jsr:@scope/quux@^0.0.0/",
},
workspace: ["./foo", "./bar", "./baz", "./qux", "./quux"],
});
},
);