The check races with the propagation of the star from one forge to the other. It must wait for it to land instead.
47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
TMPDIR=$(mktemp -d)
|
|
|
|
trap "rm -fr $TMPDIR" EXIT
|
|
|
|
source $SCENARIO_DIR/../../lib/lib.sh
|
|
|
|
function star_count() {
|
|
local curl=$1
|
|
local host_port=$2
|
|
local count=$3
|
|
|
|
$curl api_json http://$host_port/api/v1/repos/root/test > $TMPDIR/count.json
|
|
if test $count != $(jq -r .stars_count < $TMPDIR/count.json) ; then
|
|
jq . < $TMPDIR/count.json
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#
|
|
# create a repo on each instance
|
|
#
|
|
$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos > $TMPDIR/one-repo.json
|
|
one_repo_id=$(jq -r .id < $TMPDIR/one-repo.json)
|
|
$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos > $TMPDIR/two-repo.json
|
|
two_repo_id=$(jq -r .id < $TMPDIR/two-repo.json)
|
|
|
|
#
|
|
# the repo in instance two is federated with the repo in instance one
|
|
#
|
|
$ONE_CURL web --form action=federation --form following_repos=http://$TWO_HOST_PORT/api/v1/activitypub/repository-id/$two_repo_id http://$ONE_HOST_PORT/root/test/settings
|
|
|
|
#
|
|
# check that both repo have 0 star
|
|
#
|
|
star_count $ONE_CURL $ONE_HOST_PORT 0
|
|
star_count $TWO_CURL $TWO_HOST_PORT 0
|
|
|
|
#
|
|
# star the repo on instance one and expect the star to show on instance two
|
|
#
|
|
$ONE_CURL api_json -X PUT $ONE_HOST_PORT/api/v1/user/starred/root/test
|
|
|
|
#
|
|
# check that both repo have 1 star
|
|
#
|
|
star_count $ONE_CURL $ONE_HOST_PORT 1
|
|
retry star_count $TWO_CURL $TWO_HOST_PORT 1
|