Create an integration test job to test the cli against a running Gitlab instance
Currently the glab cli is tested using unit tests and mocking the GitLab API. This is good for fast feedback and reliable tests but it would be nice to be able to run the cli commands against an instance of GitLab to give a true indication of whether commands are working correctly.
Go build tags could be used to seperate these tests: https://mickey.dev/posts/go-build-tags-testing/
Ideally these tests are non-exhaustive to reduce maintenance overhead. The tests should be able to be configured to point to different instances of GitLab, this will allow us to check compatibility with previous versions.
Context: #1158 (comment 1210769380)
Pre-requisites to running tests against GDK
Command to run tests: GITLAB_TOKEN=XXX API_PROTOCOL=http GITLAB_HOST=http://192.168.4.31:3000 make test
Alternatively GDK needs to be set-up with https, see https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/nginx.md
-
Had to disable OP plugin
-
Config entry:
192.168.4.31:
token: glpat-XXX
api_host: "192.168.4.31:3000"
git_protocol: ssh
api_protocol: http
user: root
host: "192.168.4.31:3000"
-
ENV variables
API_HOST=192.168.4.31:3000;API_PROTOCOL=http;GITLAB_API_HOST=192.168.4.31:3000;GITLAB_HOST=http://192.168.4.31:3000;GITLAB_TOKEN=XXXX;GITLAB_URI=http://192.168.4.31:3000;NO_COLOR=true -
Create public group:
cli-automated-testing(manually as there is no glab command - potentially could use api or glab-api) -
git clone git@gitlab.com:cli-automated-testing/test.git -
cd test -
GITLAB_HOST=192.168.4.31 NO_PROMPT=true glab repo create test --group cli-automated-testing --defaultBranch master --public
git remote add origin ssh://git@192.168.4.31:2222/cli-automated-testing/test.git
git push -u origin --all
git push -u origin --tags
glab issue create -t test -d test- Create user called
testuser - Run a pipeline (to get data to test against)
- Change hardcoded job number to a job number that exists in the application under test
For additional tests:
- Create an MR