2018-10-30 02:34:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Disable these lint rules globally:
|
|
|
|
# 2034 = unused variable (used by sharness)
|
|
|
|
# 2016 = parameter expansion in single quotes
|
|
|
|
# 1004 = backslash-newline in single quotes
|
|
|
|
# shellcheck disable=SC2034,SC2016,SC1004
|
|
|
|
:
|
|
|
|
|
2019-05-28 15:59:50 +00:00
|
|
|
# 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.
|
|
|
|
|
2018-10-30 02:34:23 +00:00
|
|
|
test_description='test snapshot integrity for sourcecred load'
|
|
|
|
|
|
|
|
export GIT_CONFIG_NOSYSTEM=1
|
|
|
|
export GIT_ATTR_NOSYSTEM=1
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
. ./sharness.sh
|
|
|
|
|
2018-10-31 18:12:36 +00:00
|
|
|
test_expect_success "environment and Node linking setup" '
|
|
|
|
toplevel="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)" &&
|
|
|
|
snapshot_directory="${toplevel}/sharness/__snapshots__/example-github-load" &&
|
|
|
|
if [ -z "${SOURCECRED_BIN}" ]; then
|
|
|
|
printf >&2 "warn: missing environment variable SOURCECRED_BIN\n" &&
|
|
|
|
printf >&2 "warn: using repository bin directory as fallback\n" &&
|
|
|
|
export SOURCECRED_BIN="${toplevel}/bin"
|
|
|
|
fi &&
|
|
|
|
export NODE_PATH="${toplevel}/node_modules${NODE_PATH:+:${NODE_PATH}}" &&
|
|
|
|
test_set_prereq SETUP
|
|
|
|
'
|
2018-10-30 02:34:23 +00:00
|
|
|
|
|
|
|
if [ -n "${SOURCECRED_GITHUB_TOKEN:-}" ]; then
|
|
|
|
test_set_prereq HAVE_GITHUB_TOKEN
|
|
|
|
fi
|
|
|
|
|
2018-10-31 18:12:36 +00:00
|
|
|
test_expect_success EXPENSIVE,SETUP,HAVE_GITHUB_TOKEN \
|
2019-07-23 01:15:45 +00:00
|
|
|
"should load sourcecred-test/example-github" '
|
2018-10-31 18:12:36 +00:00
|
|
|
SOURCECRED_DIRECTORY=. node "${SOURCECRED_BIN}/sourcecred.js" \
|
2019-07-23 01:15:45 +00:00
|
|
|
load sourcecred-test/example-github &&
|
2018-10-30 02:34:23 +00:00
|
|
|
rm -rf cache &&
|
|
|
|
test_set_prereq LOADED_GITHUB
|
|
|
|
'
|
|
|
|
|
|
|
|
if [ -n "${UPDATE_SNAPSHOT}" ]; then
|
|
|
|
test_set_prereq UPDATE_SNAPSHOT
|
|
|
|
fi
|
|
|
|
|
2018-10-31 18:12:36 +00:00
|
|
|
test_expect_success LOADED_GITHUB,UPDATE_SNAPSHOT \
|
2018-10-30 02:34:23 +00:00
|
|
|
"should update the snapshot" '
|
|
|
|
rm -rf "$snapshot_directory" &&
|
|
|
|
cp -r . "$snapshot_directory"
|
|
|
|
'
|
|
|
|
|
2018-10-31 18:12:36 +00:00
|
|
|
test_expect_success LOADED_GITHUB "should be identical to the snapshot" '
|
2018-10-30 02:34:23 +00:00
|
|
|
diff -qr . "$snapshot_directory"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|
|
|
|
|
|
|
|
# vim: ft=sh
|