notea-de-me/app/crawler/gitlab_test.sh

47 lines
2.3 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", "type": "blob", "path": "dir/blob", "mode": "100644"}
]'
;;
'https://gitlab-app.eng.qops.net/api/v4/projects/project/repository/tree?recursive=true&path=dir/dir2' )
echo '[
{"id": "c", "name": "blob2", "type": "blob", "path": "dir/dir2/blob2", "mode": "100644"}
]'
;;
* )
return 1
;;
esac
}
__expand project dir | grep -q ^$(echo project | base64)$
__expand project dir | grep -q ^$(echo dir/blob | base64)$
__expand project dir | grep -q ^$(echo dir/dir2/blob2 | base64)$
EOF
)"
}
test_url_to_project_root() {
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
}