implement refute_server_object and assert_server_object
This commit is contained in:
parent
ec1e0f84ce
commit
9928f733a8
@ -37,7 +37,7 @@ begin_test "batch transfer unsupported on server"
|
||||
# This is a small shell function that runs several git commands together.
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# Ensure batch transfer is turned on for this repo
|
||||
git config --add --local lfs.batch true
|
||||
@ -52,7 +52,7 @@ begin_test "batch transfer unsupported on server"
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# Re-enable batch support on the server
|
||||
if [ -s "$LFS_URL_FILE" ]; then
|
||||
|
@ -43,7 +43,7 @@ begin_test "batch transfer"
|
||||
# This is a small shell function that runs several git commands together.
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# Ensure batch transfer is turned on for this repo
|
||||
git config --add --local lfs.batch true
|
||||
@ -53,7 +53,7 @@ begin_test "batch transfer"
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# change to the clone's working directory
|
||||
cd ../clone
|
||||
|
@ -43,7 +43,7 @@ begin_test "chunked transfer encoding batched"
|
||||
# This is a small shell function that runs several git commands together.
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# Ensure batch transfer is turned on for this repo
|
||||
git config --add --local lfs.batch true
|
||||
@ -53,7 +53,7 @@ begin_test "chunked transfer encoding batched"
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# change to the clone's working directory
|
||||
cd ../clone
|
||||
|
@ -44,14 +44,14 @@ begin_test "chunked transfer encoding"
|
||||
# This is a small shell function that runs several git commands together.
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# This pushes to the remote repository set up at the top of the test.
|
||||
git push origin master 2>&1 | tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# change to the clone's working directory
|
||||
cd ../clone
|
||||
|
@ -32,13 +32,13 @@ begin_test "fetch"
|
||||
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
git push origin master 2>&1 | tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# Add a file in a different branch
|
||||
git checkout -b newbranch
|
||||
@ -50,7 +50,7 @@ begin_test "fetch"
|
||||
assert_pointer "newbranch" "b.dat" "$b_oid" 1
|
||||
|
||||
git push origin newbranch
|
||||
assert_server_object "$b_id" "$b"
|
||||
assert_server_object "$reponame" "$b_oid"
|
||||
|
||||
# change to the clone's working directory
|
||||
cd ../clone
|
||||
|
@ -44,14 +44,14 @@ begin_test "happy path"
|
||||
# This is a small shell function that runs several git commands together.
|
||||
assert_pointer "master" "a.dat" "$contents_oid" 1
|
||||
|
||||
refute_server_object "$contents_oid"
|
||||
refute_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# This pushes to the remote repository set up at the top of the test.
|
||||
git push origin master 2>&1 | tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
grep "master -> master" push.log
|
||||
|
||||
assert_server_object "$contents_oid" "$contents"
|
||||
assert_server_object "$reponame" "$contents_oid"
|
||||
|
||||
# change to the clone's working directory
|
||||
cd ../clone
|
||||
|
@ -25,13 +25,7 @@ begin_test "pre-push"
|
||||
git commit -m "add hi.dat"
|
||||
git show
|
||||
|
||||
# file isn't on the git lfs server yet
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4" \
|
||||
-u "user:pass" \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
|
||||
grep "404 Not Found" http.log
|
||||
refute_server_object "$reponame" 98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4
|
||||
|
||||
# push file to the git lfs server
|
||||
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
|
||||
@ -39,18 +33,7 @@ begin_test "pre-push"
|
||||
tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
|
||||
# now the file exists
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4" \
|
||||
-u "user:pass" \
|
||||
-o lfs.json \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "200 OK" http.log
|
||||
|
||||
grep "download" lfs.json || {
|
||||
cat lfs.json
|
||||
exit 1
|
||||
}
|
||||
assert_server_object "$reponame" 98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4
|
||||
)
|
||||
end_test
|
||||
|
||||
@ -78,24 +61,15 @@ begin_test "pre-push dry-run"
|
||||
git commit -m "add hi.dat"
|
||||
git show
|
||||
|
||||
# file doesn't exist yet
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/2840e0eafda1d0760771fe28b91247cf81c76aa888af28a850b5648a338dc15b" \
|
||||
-u "user:pass" \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "404 Not Found" http.log
|
||||
refute_server_object "$reponame" 2840e0eafda1d0760771fe28b91247cf81c76aa888af28a850b5648a338dc15b
|
||||
|
||||
echo "refs/heads/master master refs/heads/master 0000000000000000000000000000000000000000" |
|
||||
git lfs pre-push --dry-run origin "$GITSERVER/$reponame" 2>&1 |
|
||||
tee push.log
|
||||
grep "push hi.dat" push.log
|
||||
[ `wc -l < push.log` = 1 ]
|
||||
|
||||
# file still doesn't exist
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/2840e0eafda1d0760771fe28b91247cf81c76aa888af28a850b5648a338dc15b" \
|
||||
-u "user:pass" \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "404 Not Found" http.log
|
||||
refute_server_object "$reponame" 2840e0eafda1d0760771fe28b91247cf81c76aa888af28a850b5648a338dc15b
|
||||
)
|
||||
end_test
|
||||
|
||||
@ -126,18 +100,7 @@ begin_test "pre-push 307 redirects"
|
||||
tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
|
||||
# now the file exists
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4" \
|
||||
-u "user:pass" \
|
||||
-o lfs.json \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "200 OK" http.log
|
||||
|
||||
grep "download" lfs.json || {
|
||||
cat lfs.json
|
||||
exit 1
|
||||
}
|
||||
assert_server_object "$reponame" 98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4
|
||||
|
||||
# absolute redirect
|
||||
git config remote.origin.lfsurl "$GITSERVER/redirect307/abs/$reponame.git/info/lfs"
|
||||
@ -182,17 +145,7 @@ begin_test "pre-push with existing file"
|
||||
grep "(1 of 1 files)" push.log
|
||||
|
||||
# now the file exists
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/7aa7a5359173d05b63cfd682e3c38487f3cb4f7f1d60659fe59fab1505977d4c" \
|
||||
-u "user:pass" \
|
||||
-o lfs.json \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "200 OK" http.log
|
||||
|
||||
grep "download" lfs.json || {
|
||||
cat lfs.json
|
||||
exit 1
|
||||
}
|
||||
assert_server_object "$reponame" 7aa7a5359173d05b63cfd682e3c38487f3cb4f7f1d60659fe59fab1505977d4c
|
||||
)
|
||||
end_test
|
||||
|
||||
|
@ -20,14 +20,38 @@ assert_pointer() {
|
||||
fi
|
||||
}
|
||||
|
||||
# no-op. check that the object does not exist in the git lfs server
|
||||
# check that the object does not exist in the git lfs server. HTTP log is
|
||||
# written to http.log. JSON output is written to http.json.
|
||||
#
|
||||
# $ refute_server_object "reponame" "oid"
|
||||
refute_server_object() {
|
||||
echo "refute server object: no-op"
|
||||
local reponame="$1"
|
||||
local oid="$2"
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/$oid" \
|
||||
-u "user:pass" \
|
||||
-o http.json \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
|
||||
grep "404 Not Found" http.log
|
||||
}
|
||||
|
||||
# no-op. check that the object does exist in the git lfs server
|
||||
# check that the object does exist in the git lfs server. HTTP log is written
|
||||
# to http.log. JSON output is written to http.json.
|
||||
assert_server_object() {
|
||||
echo "assert server object: no-op"
|
||||
local reponame="$1"
|
||||
local oid="$2"
|
||||
curl -v "$GITSERVER/$reponame.git/info/lfs/objects/$oid" \
|
||||
-u "user:pass" \
|
||||
-o http.json \
|
||||
-H "Accept: application/vnd.git-lfs+json" 2>&1 |
|
||||
tee http.log
|
||||
grep "200 OK" http.log
|
||||
|
||||
grep "download" http.json || {
|
||||
cat http.json
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# pointer returns a string Git LFS pointer file.
|
||||
|
Loading…
Reference in New Issue
Block a user