forked from firecow/gitlab-ci-local
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration.test.ts
More file actions
68 lines (51 loc) · 2.34 KB
/
Copy pathintegration.test.ts
File metadata and controls
68 lines (51 loc) · 2.34 KB
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
import {WriteStreamsMock} from "../../../src/write-streams.js";
import {handler} from "../../../src/handler.js";
import {initSpawnSpy} from "../../mocks/utils.mock.js";
import {WhenStatics} from "../../mocks/when-statics.js";
beforeAll(() => {
initSpawnSpy(WhenStatics.all);
const spyGitRemote = {
cmdArgs: ["git", "remote", "get-url", "origin"],
returnValue: {stdout: "https://gitlab.com/firecow/gitlab-ci-local.git"},
};
initSpawnSpy([...WhenStatics.all, spyGitRemote]);
});
test.concurrent("include:project be able to target branch via ref", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
file: ".gitlab-ci-1.yml",
cwd: "tests/test-cases/include-project-file",
noColor: true,
stateDir: ".gitlab-ci-local-include-project-file-ref",
}, writeStreams);
const expected = "job > hello world from dev branch";
const filteredStdout = writeStreams.stdoutLines.filter(f => f.startsWith("job >")).join("\n");
expect(filteredStdout).toEqual(expected);
});
test.concurrent("include:project should target default branch when ref is missing", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
file: ".gitlab-ci-2.yml",
cwd: "tests/test-cases/include-project-file",
noColor: true,
stateDir: ".gitlab-ci-local-include-project-file-default-branch",
}, writeStreams);
const expected = "job > hello world from default branch";
const filteredStdout = writeStreams.stdoutLines.filter(f => f.startsWith("job >")).join("\n");
expect(filteredStdout).toEqual(expected);
});
test.concurrent("include:project should respect rules specified in included project", async () => {
const writeStreams = new WriteStreamsMock();
await handler({
file: ".gitlab-ci-3.yml",
cwd: "tests/test-cases/include-project-file",
noColor: true,
list: true,
stateDir: ".gitlab-ci-local-include-project-file-rules",
}, writeStreams);
const expected = [
"name description stage when allow_failure environment needs",
"should execute since rule eval to true test on_success false ",
];
expect(writeStreams.stdoutLines.join("\n")).toEqual(expected.join("\n"));
});