Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty spaces uncorrectly detected as positional argument #626

Merged
merged 4 commits into from Jan 16, 2023

Conversation

sinedied
Copy link
Member

@sinedied sinedied commented Jan 9, 2023

Empty spaces are currently misdetected as positional arguments, for example swa deploy --output-location dist will incorrectly interpret the space as a positional argument and print an error because it conflicts with the output-location option.

This PR fixes that.

@github-actions github-actions bot added the scope: cli Issues happened a the ./src/cli level label Jan 9, 2023
it("should not interpret empty spaces as a positional argument", async () => {
const execSyncMock = jest.requireMock("child_process").execSync;
mockFs();
await run(["node", "swa", "build", " ", "--app-build-command", "npm run something", " "]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks! @sinedied for adding the test for swa build..

Just to confirm if these tests cover the changes we did in deploy.ts/start.ts if not will it make sense for us to add separate tests for those scenarios ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added logic is the same for build/start/deploy, so it should validate these changes, but not cover it in case of refactor of start/deploy.

Currently there's no tests (at all) for the cli commands deploy/start/login, hence why I reused the mocks made for the build command tests. Adding minimal tests for these commands would be useful, though not the scope of this PR.

@sulabh-msft
Copy link
Contributor

@sgollapudi77 / @rupareddy5-21 Can you also please review the PR ?

Copy link
Contributor

@sulabh-msft sulabh-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the PR .. Please check if the tests added cover the changes for deply and start as well.

@sinedied
Copy link
Member Author

sinedied commented Jan 9, 2023

Hmmm, seems in some Node environments jest fails to restore properly the "child_process" mocks. making the tests fail. I had a hard time finding a workaround already locally, I'll try to use another approach then and refactor the code a bit.

@sinedied
Copy link
Member Author

sinedied commented Jan 9, 2023

Tests are passing now. I refactored the cli commands architecture a bit to split the registering (=doc and options parsing) and the execution parts. Testing individual commands and their components should be easier now.

@sulabh-msft
Copy link
Contributor

@sinedied looks like there is one merge conflict. Can you please resolve the merge conflict ?

@sinedied
Copy link
Member Author

@sulabh-msft I've updated the branch, no more conflict :)

@sulabh-msft sulabh-msft merged commit 67d380d into main Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: cli Issues happened a the ./src/cli level
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants