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

Don't compare internal and dto types in variant-analysis-history.test.ts #3293

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

robertbrignull
Copy link
Contributor

In variant-analysis-history.test.ts we are reading the raw query history DTO types from a file and then trying to compare them to the internal types from the query history manager. On main this happens to work because the types are the same, but the whole point of having these two types is that they don't have to be the same.

The "workspace-query-history.json" file is where the query history manager also loads its data from. However in the tests we never actually want it as this raw data and instead just want to make sure it's done the loading correctly.

Similar to #3290, I found this because of a test failure on https://github.com/github/vscode-codeql/actions/runs/7699342606/job/20983096500?pr=3287 where the internal types are changing but the DTO types are not.

Checklist

  • 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.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@robertbrignull robertbrignull requested review from a team as code owners January 30, 2024 12:39
join(STORAGE_DIR, "workspace-query-history.json"),
).queries;
).queries.map(mapQueryHistoryVariantAnalysisToDomainModel);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I'm not totally clear on is what exactly we're testing. So is it appropriate to use mapQueryHistoryVariantAnalysisToDomainModel to generate the expected data, or are we basically just calling the same function twice and comparing the result?

I also tried writing out the expected data manually and explicitly, instead of loading it from this file. The issues I ran into were:

  • we duplicate a lot of data (but that's kinda the point)
  • the data contains some PLACEHOLDERs in the file paths, because we don't know where the file will be written so we can't hard-code the path to the QL files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I don't think using mapQueryHistoryVariantAnalysisToDomainModel is any different from what the test is doing right now, which is also essentially checking some data against itself.

At least we're still verifying that it can parse the data without erroring and at least we get something out at the other end 🤷🏼

Copy link
Contributor

@charisk charisk left a comment

Choose a reason for hiding this comment

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

Seems reasonable!

@robertbrignull robertbrignull merged commit 222d3ed into main Jan 30, 2024
15 checks passed
@robertbrignull robertbrignull deleted the robertbrignull/variant-analysis-history-test-dto branch January 30, 2024 14:32
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