mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-26 04:20:01 +00:00
Add a universal snapshot updater (#1159)
As SourceCred has evolved, we've grown more and more snapshot tests that are not included in Jest. The GitHub plugin has two ad-hoc snapshot tests, the Git plugin has one, and the sharness test suites have one. This makes it difficult to keep track of where to update snapshots when core changes are made. To fix this, I've added a script, `scripts/update_snapshots.sh`, which updates snapshot tests across the project. Test plan: I removed existing snapshots across the codebase, ran the snapshot tester, and they correctly regenerated.
This commit is contained in:
parent
e01247a642
commit
14eee06799
19
scripts/update_snapshots.sh
Executable file
19
scripts/update_snapshots.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Automatically update all SourceCred snapshot data.
|
||||
set -eu
|
||||
|
||||
toplevel="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
|
||||
cd "${toplevel}"
|
||||
|
||||
yarn backend
|
||||
echo "Updating for sharness/test_load_example_github.t"
|
||||
(cd sharness; UPDATE_SNAPSHOT=1 ./test_load_example_github.t -l)
|
||||
echo "Updating git/loadRepositoryTest.sh"
|
||||
./src/plugins/git/loadRepositoryTest.sh -u
|
||||
echo "Updating github/fetchGithubOrgTest.sh"
|
||||
./src/plugins/github/fetchGithubOrgTest.sh -u --no-build
|
||||
echo "Updating github/fetchGithubRepoTest.sh"
|
||||
./src/plugins/github/fetchGithubRepoTest.sh -u --no-build
|
||||
echo "Updating Jest snapshots"
|
||||
yarn unit -u
|
@ -7,6 +7,10 @@
|
||||
# shellcheck disable=SC2034,SC2016,SC1004
|
||||
:
|
||||
|
||||
# If this test is failing, it probably means you need to update snapshots.
|
||||
# You can do so by setting your SOURCECRED_GITHUB_TOKEN (see README) and then
|
||||
# running scripts/update_snapshots.sh.
|
||||
|
||||
test_description='test snapshot integrity for sourcecred load'
|
||||
|
||||
export GIT_CONFIG_NOSYSTEM=1
|
||||
|
@ -5,16 +5,11 @@ data is generated by running our GitHub API fetch against the SourceCred
|
||||
example repo at https://github.com/sourcecred/example-github/.
|
||||
|
||||
The demo data should be regenerated any time either the example repository or
|
||||
the GitHub api query changes. To regenerate the demo data, run the following
|
||||
command:
|
||||
the GitHub api query changes. To regenerate the demo data, you can run the general-purpose
|
||||
snapshot updater:
|
||||
|
||||
```shell
|
||||
$ SOURCECRED_GITHUB_TOKEN="your_token_here" src/plugins/github/fetchGithubRepoTest.sh -u
|
||||
```
|
||||
|
||||
You can also just verify that the data is up-to-date by running:
|
||||
```shell
|
||||
$ SOURCECRED_GITHUB_TOKEN="your_token_here" src/plugins/github/fetchGithubRepoTest.sh
|
||||
$ SOURCECRED_GITHUB_TOKEN="your_token_here" scripts/update_snapshots.sh
|
||||
```
|
||||
|
||||
There is a known issue where GitHub's end cursor output depends on your current
|
||||
|
Loading…
x
Reference in New Issue
Block a user