Skip to content

Commit

Permalink
fix(lift): handle lifting when no tags are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Jul 10, 2024
1 parent 9238560 commit 37de34e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lifter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function ({projectRoot, results: {projectDetails: {homepage
config: {
repository: {
homepage,
topics: tags.join(', ')
...tags && {topics: tags.join(', ')}
}
}
});
Expand Down
23 changes: 21 additions & 2 deletions src/lifter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ vi.mock('@form8ion/core');
describe('lifter', () => {
const projectRoot = any.simpleObject();
const tags = any.listOf(any.word);
const homepage = any.url();

it('should set properties in the settings file', async () => {
const homepage = any.url();

const result = await lift({
projectRoot,
results: {
Expand Down Expand Up @@ -55,4 +54,24 @@ describe('lifter', () => {
}
});
});

it('should not result in an error when tags are not provided in the results', async () => {
await lift({
projectRoot,
results: {
projectDetails: {homepage}
}
});

expect(mergeIntoExistingConfigFile).toHaveBeenCalledWith({
format: fileTypes.YAML,
path: `${projectRoot}/.github`,
name: 'settings',
config: {
repository: {
homepage
}
}
});
});
});
11 changes: 10 additions & 1 deletion test/integration/features/lift.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ Feature: Lift
Scenario: Lift
Given the GitHub repository settings are managed by the repository-settings app
And the scaffolder results include projectDetails
And the scaffolder results include tags
When scaffolder results are processed
Then properties are updated in the settings file

Scenario: Lift w/o project details
Given the GitHub repository settings are managed by the repository-settings app
And the scaffolder results do not include projectDetails
And the scaffolder results include tags
But the scaffolder results do not include projectDetails
When scaffolder results are processed
Then properties are updated in the settings file

Scenario: Lift w/o tags
Given the GitHub repository settings are managed by the repository-settings app
And the scaffolder results include projectDetails
But the scaffolder results do not include tags
When scaffolder results are processed
Then properties are updated in the settings file

Expand Down
2 changes: 0 additions & 2 deletions test/integration/features/step_definitions/common-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ When('the project is scaffolded', async function () {
});

When('scaffolder results are processed', async function () {
this.tags = any.listOf(any.word);

if (await test({projectRoot: this.projectRoot})) {
await lift({
projectRoot: this.projectRoot,
Expand Down
8 changes: 8 additions & 0 deletions test/integration/features/step_definitions/results-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ Given('the scaffolder results include projectDetails', async function () {
this.homepage = any.url();
this.projectDetails = {homepage: this.homepage};
});

Given('the scaffolder results include tags', async function () {
this.tags = any.listOf(any.word);
});

Given('the scaffolder results do not include tags', async function () {
return undefined;
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Then('properties are updated in the settings file', async function () {
repository: {
...this.existingSettingsContent.repository,
...this.homepage && {homepage: this.homepage},
topics: this.tags.join(', ')
...this.tags && {topics: this.tags.join(', ')}
}
}
);
Expand Down

0 comments on commit 37de34e

Please sign in to comment.