Skip to content

Commit

Permalink
ci-cd: use runCli in test
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Sep 25, 2024
1 parent c53dd03 commit f20a600
Showing 1 changed file with 53 additions and 10 deletions.
63 changes: 53 additions & 10 deletions generators/ci-cd/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,10 @@ describe(`generator - ${generator}`, () => {
shouldSupportFeatures(Generator);
describe('blueprint support', () => testBlueprintSupport(generator));

describe('questions', () => {
describe('without answers', () => {
describe('cli', () => {
describe('without ciCd values', () => {
before(async () => {
await helpers
.runJHipster('ci-cd')
.withJHipsterConfig()
.withOptions({
// ciCd argument is a varargs, pass an empty array to check if ciCd prompt is asked
positionalArguments: [[]],
})
.withSkipWritingPriorities();
await helpers.runCli('ci-cd').withJHipsterConfig().withSkipWritingPriorities();
});

it('should match order', () => {
Expand All @@ -56,6 +49,56 @@ describe(`generator - ${generator}`, () => {
"ciCd",
"ciCdIntegrations",
]
`);
});
});

describe('with invalid ciCd value', () => {
it('should exit with error', async () => {
await expect(
helpers.runCli('ci-cd foo').withJHipsterConfig().withSkipWritingPriorities(),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"error: command-argument value 'foo' is invalid for argument 'ciCd'. Allowed choices are github, jenkins, gitlab, azure, travis, circle."`,
);
});
});

describe('with multiples values', () => {
before(async () => {
await helpers.runCli('ci-cd github jenkins gitlab azure').withJHipsterConfig().withSkipWritingPriorities();
});

it('should match order', () => {
expect(runResult.generator.context!.ciCd).toEqual(['github', 'jenkins', 'gitlab', 'azure']);
});
});

describe('with github', () => {
before(async () => {
await helpers.runCli('ci-cd github').withJHipsterConfig().withSkipWritingPriorities();
});

it('should not ask ciCd question', () => {
expect(runResult.askedQuestions.map(({ name }) => name)).toMatchInlineSnapshot(`
[
"ciCdIntegrations",
]
`);
});
});

describe('with jenkins', () => {
before(async () => {
await helpers.runCli('ci-cd jenkins').withJHipsterConfig().withSkipWritingPriorities();
});

it('should not ask ciCd question', () => {
expect(runResult.askedQuestions.map(({ name }) => name)).toMatchInlineSnapshot(`
[
"ciCdIntegrations",
"insideDocker",
"sendBuildToGitlab",
]
`);
});
});
Expand Down

0 comments on commit f20a600

Please sign in to comment.