Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/data-expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export function needsComplex (data: any) {
export function needsEach (jobName: string, gitlabData: any) {
const jobData = gitlabData[jobName];
if (!jobData.needs) return;
assert(Array.isArray(jobData.needs), chalk`{blueBright ${jobName}} {yellow needs:} must be an array`);
Comment thread
firecow marked this conversation as resolved.

for (const [i, n] of Object.entries<any>(jobData.needs)) {
jobData.needs[i] = needsComplex(n);
Expand Down
9 changes: 9 additions & 0 deletions tests/test-cases/needs-not-array/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
build-job:
script:
- echo "build"

dev-job:
needs: build-job
script:
- echo "dev"
18 changes: 18 additions & 0 deletions tests/test-cases/needs-not-array/integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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";
import chalk from "chalk-template";

beforeAll(() => {
initSpawnSpy(WhenStatics.all);
});

test.concurrent("needs-not-array <dev-job>", async () => {
const writeStreams = new WriteStreamsMock();

await expect(handler({
cwd: "tests/test-cases/needs-not-array",
stateDir: ".gitlab-ci-local-needs-not-array",
}, writeStreams)).rejects.toThrow(chalk`{blueBright dev-job} {yellow needs:} must be an array`);
});