Add ability to define repo lists in a file outside of settings#1402
Add ability to define repo lists in a file outside of settings#1402
Conversation
|
🤔 I have some tests that work fine if I have |
extensions/ql-vscode/src/remote-queries/repository-selection.ts
Outdated
Show resolved
Hide resolved
| const repoListsFromSetings = readRepoListsFromSettings(); | ||
| const repoListsFromExternalFile = await readExternalRepoLists(); | ||
|
|
||
| return [...repoListsFromSetings, ...repoListsFromExternalFile]; |
There was a problem hiding this comment.
What happens if a repo list from settings and a repo list from a file have the same name? Currently, they will both show indistinguishably. We probably don't want to merge them. It also probably shouldn't be an error.
So, if there's a duplicate, can you label them differently (eg- foo (from file) and foo (from settings)?
There was a problem hiding this comment.
The agreement with Product is that we'd do nothing for now in the case of duplicates and see how the feature is used (specially considering re-design work).
| let pathExistsStub: sinon.SinonStub; | ||
| let fsStatStub: sinon.SinonStub; | ||
| let fsReadFileStub: sinon.SinonStub; |
There was a problem hiding this comment.
The problem is that these stubs are not being used in the file where you expect them to.
The actual fs and path functions are being called. This is why when you run these tests separately they pass, but when you run as a whole, they fail.
To fix this, you need to pass the stubs in through the call to proxyquire. The default behaviour of proxyquire is to call through stubbed out modules so that the original function is called. What you would do is something like this:
- create mock fs and path instances (just empty objects initially)
- pass these into the call to proxyquire on line 23
- in the beforeEach block on line 187, add the stubs directly to the empty objects
I think this should work.
All this stuff is much easier to do using jest, but it's a big change to move from mocha to jest, so I think we're stuck.
There was a problem hiding this comment.
Thank you so much for the write up! My eyes somehow completely glazed over the proxyrequire stuff 😬
The explanation makes sense (and works! 🎉) - only thing I don't get is why it'd work if I ran the tests on their own. I'll go away and do some reading around it. Thanks again!
There was a problem hiding this comment.
I think it passed because somehow the tests were set up in a way that they would pass in a clean environment, but not one where other tests have already created state. I haven't looked at the details though.
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
…b/vscode-codeql into charisk/external-repo-list
Adds a new
repositoryListsPathsetting that allows users to define repository lists for MRVA outside of their settings.json file.Checklist
N/A:
ready-for-doc-reviewlabel there.