70 lines
3.1 KiB
Bash
70 lines
3.1 KiB
Bash
#! /bin/bash
|
|
|
|
test___expand() {
|
|
gitlab eval "$(cat <<EOF
|
|
_gcurl() {
|
|
case "\$1" in
|
|
'https://gitlab-app.eng.qops.net/api/v4/projects/project/repository/tree?recursive=true&path=dir' )
|
|
echo '[
|
|
{"id": "a", "name": "dir2", "type": "tree", "path": "dir/dir2", "mode": "040000"},
|
|
{"id": "b", "name": "blob.md", "type": "blob", "path": "dir/blob.md", "mode": "100644"}
|
|
]'
|
|
;;
|
|
'https://gitlab-app.eng.qops.net/api/v4/projects/project/repository/tree?recursive=true&path=dir/dir2' )
|
|
echo '[
|
|
{"id": "c", "name": "blob2.txt", "type": "blob", "path": "dir/dir2/blob2.txt", "mode": "100644"},
|
|
{"id": "c", "name": "blob3.jpg", "type": "blob", "path": "dir/dir2/blob3.jpg", "mode": "100644"}
|
|
]'
|
|
;;
|
|
* )
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
local blob=false
|
|
local dir2blob2=false
|
|
local others=0
|
|
for result in \$(__expand project dir); do
|
|
if echo \$result | base64 --decode | grep -q ^blob.md$; then
|
|
blob=true
|
|
elif echo \$result | base64 --decode | grep -q ^dir2.blob2.txt$; then
|
|
dir2blob2=true
|
|
else
|
|
others=\$((others+1))
|
|
fi
|
|
done
|
|
if [ \$others != 0 ]; then
|
|
return 101
|
|
fi
|
|
if ! \$blob; then
|
|
return 102
|
|
fi
|
|
if ! \$dir2blob2; then
|
|
return 103
|
|
fi
|
|
EOF
|
|
)"
|
|
}
|
|
|
|
test_url_to_project_root() {
|
|
log() { true; };
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/tree/master | grep -q '^data-store/orchestration/runbooks$'
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/tree/master | tail -n 1 | grep ^$
|
|
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/blob/master/Alerts/rems/README.md | grep -q 'data-store/orchestration/runbooks'
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/blob/master/Alerts/rems/README.md | grep -q 'Alerts/rems/README.md'
|
|
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/tree/master/Alerts | grep -q 'data-store/orchestration/runbooks'
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/tree/master/Alerts | grep -q 'Alerts'
|
|
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks | grep -q 'data-store/orchestration/runbooks'
|
|
gitlab _url_to_project_root https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks | grep -q '^$'
|
|
}
|
|
|
|
test_is() {
|
|
gitlab is https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/blob/master/Alerts/rems/README.md
|
|
gitlab is https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks/-/tree/master/Alerts
|
|
gitlab is https://gitlab-app.eng.qops.net/data-store/orchestration/runbooks
|
|
! gitlab is https://gitlab-app.eng.qops.net/surveys/marauders-map/wikis/Customer-impact-of-an-outage
|
|
}
|