github.com/2lambda123/git-lfs@v2.5.2+incompatible/t/t-push-failures-remote.sh (about) 1 #!/usr/bin/env bash 2 3 . "$(dirname "$0")/testlib.sh" 4 5 # push_fail_test preforms a test expecting a `git lfs push` to fail given the 6 # contents of a particular file contained within that push. The Git server used 7 # during tests has certain special cases that are triggered by finding specific 8 # keywords within a file (as given by the first argument). 9 # 10 # An optional second argument can be included, "msg", that assert that the 11 # contents "msg" was included in the output of a `git lfs push`. 12 push_fail_test() { 13 local contents="$1" 14 local msg="$2" 15 16 set -e 17 18 local reponame="$(basename "$0" ".sh")-$contents" 19 setup_remote_repo "$reponame" 20 clone_repo "$reponame" "$reponame" 21 22 git lfs track "*.dat" 23 printf "hi" > good.dat 24 printf "$contents" > bad.dat 25 git add .gitattributes good.dat bad.dat 26 git commit -m "welp" 27 28 set +e 29 git push origin master 2>&1 | tee push.log 30 res="${PIPESTATUS[0]}" 31 set -e 32 33 if [ ! -z "$msg" ]; then 34 grep "$msg" push.log 35 fi 36 37 refute_server_object "$reponame" "$(calc_oid "$contents")" 38 if [ "$res" = "0" ]; then 39 echo "push successful?" 40 exit 1 41 fi 42 } 43 44 begin_test "push: upload file with storage 403" 45 ( 46 set -e 47 48 push_fail_test "status-storage-403" 49 ) 50 end_test 51 52 begin_test "push: upload file with storage 404" 53 ( 54 set -e 55 56 push_fail_test "status-storage-404" 57 ) 58 end_test 59 60 begin_test "push: upload file with storage 410" 61 ( 62 set -e 63 64 push_fail_test "status-storage-410" 65 ) 66 end_test 67 68 begin_test "push: upload file with storage 500" 69 ( 70 set -e 71 72 push_fail_test "status-storage-500" 73 ) 74 end_test 75 76 begin_test "push: upload file with storage 503" 77 ( 78 set -e 79 80 push_fail_test "status-storage-503" "LFS is temporarily unavailable" 81 ) 82 end_test 83 84 begin_test "push: upload file with api 403" 85 ( 86 set -e 87 88 push_fail_test "status-batch-403" 89 ) 90 end_test 91 92 begin_test "push: upload file with api 404" 93 ( 94 set -e 95 96 push_fail_test "status-batch-404" 97 ) 98 end_test 99 100 begin_test "push: upload file with api 410" 101 ( 102 set -e 103 104 push_fail_test "status-batch-410" 105 ) 106 end_test 107 108 begin_test "push: upload file with api 422" 109 ( 110 set -e 111 112 push_fail_test "status-batch-422" 113 ) 114 end_test 115 116 begin_test "push: upload file with api 500" 117 ( 118 set -e 119 120 push_fail_test "status-batch-500" 121 ) 122 end_test