-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.test.js
63 lines (59 loc) · 1.87 KB
/
github.test.js
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
const { exec } = require("child_process");
const {
repoOwner,
repoName,
correctBranch,
wrongBranch,
} = require("./test.common.js");
describe("github.js", () => {
describe("commit command", () => {
test("commit command, good branch", (done) => {
exec(
`node github.js commit -o ${repoOwner} -r ${repoName} -b ${correctBranch} -c dummy/file1.txt -m "this is a commit msg"`,
(error, stdout, stderr) => {
expect(error).toBeNull();
expect(stdout).toContain(
`Commit created: https://github.com/${repoOwner}/${repoName}/commit`
);
done();
}
);
}, 10000);
test("commit command, BAD branch", (done) => {
exec(
`node github.js commit -o ${repoOwner} -r ${repoName} -b ${wrongBranch} -c dummy/file1.txt -m "this is a commit msg"`,
(error, stdout, stderr) => {
expect(error).not.toBeNull();
expect(stderr).toMatch(/Failed to create commit:/);
done();
}
);
}, 10000);
});
describe("branch command", () => {
test("branch command, good branch", (done) => {
exec(
`node github.js branch -o ${repoOwner} -r ${repoName} -b ${correctBranch}`,
(error, stdout, stderr) => {
expect(error).toBeNull();
expect(stdout).toContain(
`Repository ${repoOwner}/${repoName} has a branch named '${correctBranch}'`
);
done();
}
);
}, 10000);
test("branch command, BAD branch", (done) => {
exec(
`node github.js branch -o ${repoOwner} -r ${repoName} -b ${wrongBranch}`,
(error, stdout, stderr) => {
expect(error).toBeNull();
expect(stdout).toContain(
`Repository ${repoOwner}/${repoName} has no branch named '${wrongBranch}'`
);
done();
}
);
}, 10000);
});
});