Change database.test.js
to better test package renaming
#269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tests for package renaming scenarios.
The main difference is that these use
insertNewPackageVersion
instead ofinsertNewPackageName
. The latter is no longer really used;insertNewPackageVersion
also better captures the fact that a renamed package necessarily has at least two versions.I'd changed
getPackageByName.js
locally in such a way as to make these tests pass, but my approach locally won't actually work; the database migration proposed by @confused-Techie is wiser. My way of figuring out a package's canonical name was to find out what the name was on the most recently published version of the package, but that approach won't work if a package is renamed and then the version associated with the renaming is deleted. In that scenario, we need a way of figuring out that the newer package name is still canonical even though there aren't any (non-deleted) package versions under that name.