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

Tidy and add tests for resolveLanguages commands #937

Merged
merged 3 commits into from
Sep 1, 2021

Conversation

shati-patel
Copy link
Contributor

@shati-patel shati-patel commented Aug 31, 2021

First stage of tidying up and adding tests. See #915 (review) and the linked (internal) issue.

  • I've moved findLanguage out of "run-remote-query" and into a more general place ("helpers"), since it's used in a few functions and this seemed like a more logical place
  • Added a test for resolveLanguages (basically copied from the resolveQlpacks test above 😅)

I haven't yet added a test for the other functions from #915, since they require a bit more setup. Stay tuned for a follow-up PR 😎

Checklist

N/A: no user-facing changes

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • @github/docs-content-codeql has been cc'd in all issues for UI or other user-facing changes made by this pull request.

@shati-patel shati-patel marked this pull request as ready for review August 31, 2021 17:40
@shati-patel shati-patel requested a review from a team as a code owner August 31, 2021 17:40
Copy link
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

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

Nice! One minor suggestion that I thought of from reading the existing code and the Chai docs. There are of course many equivalent ways of writing the same test, so pick whatever you think is clear and readable.

Comment on lines 60 to 64
expect(languages['cpp']).not.to.be.undefined;
expect(languages['csharp']).not.to.be.undefined;
expect(languages['java']).not.to.be.undefined;
expect(languages['javascript']).not.to.be.undefined;
expect(languages['python']).not.to.be.undefined;
Copy link
Contributor

@adityasharad adityasharad Aug 31, 2021

Choose a reason for hiding this comment

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

Reading the Chai docs, I think there's an equivalent way of writing what we had before, with the added advantage of giving a more helpful message if the key is missing. Does this work?

for (const expectedLanguage of ['cpp', 'csharp', 'go', 'java', 'javascript', 'python']) {
  expect(languages).to.have.property(expectedLanguage).that.is.not.undefined;
}

I also added Go since we can expect that to exist, might as well test all supported languages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, that looks nicer! (and also works 😄)

I'll merge this and start looking at more interesting tests in a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants