http method gitlab GET /api/v4/user 200 {"id": 555}
http method gitlab GET /api/v4/projects/1234/merge_requests/1/versions 200 [{"id": 2, "head_commit_sha": "head", "base_commit_sha": "base", "start_commit_sha": "start"},{"id": 1, "head_commit_sha": "head", "base_commit_sha": "base", "start_commit_sha": "start"}]
http method gitlab GET /api/v4/projects/1234/merge_requests/1/discussions 200 [{"id": "500", "notes": [{"id": 501, "author": {"id": 555}, "system": false, "body": "stale general comment from previous pint run"}]}]
http method gitlab GET /api/v4/projects/1234/merge_requests 200 [{"iid": 1}]
http method gitlab PUT /api/v4/projects/1234/merge_requests/1/discussions/500 200 {}
http start gitlab 127.0.0.1:6272

mkdir testrepo
cd testrepo
exec git init --initial-branch=main .

cp ../src/v1.yml rules.yml
cp ../src/.pint.hcl .
env GIT_AUTHOR_NAME=pint
env GIT_AUTHOR_EMAIL=pint@example.com
env GIT_COMMITTER_NAME=pint
env GIT_COMMITTER_EMAIL=pint@example.com
exec git add .
exec git commit -am 'import rules and config'

exec git checkout -b v2
cp ../src/v2.yml rules.yml
exec git commit -am 'v2'

env GITLAB_AUTH_TOKEN=secret
exec pint -l debug --offline --no-color ci
! stdout .
stderr 'level=INFO msg="Deleting stale general comment" reporter=GitLab id=501'
cmp gitlab.got ../gitlab.expected

-- src/v1.yml --
groups:
- name: foo
  rules:
  - record: foo
    expr: sum(up)
    labels:
      cluster: dev

-- src/v2.yml --
groups:
- name: foo
  rules:
  - record: foo
    expr: sum(up)
    labels:
      cluster: prod

-- src/.pint.hcl --
ci {
  baseBranch = "main"
}
repository {
  gitlab {
    uri        = "http://127.0.0.1:6272"
    timeout    = "30s"
    project    = "1234"
  }
}

-- gitlab.expected --
GET /api/v4/user
  Accept: application/json
  Accept-Encoding: gzip
  Private-Token: secret

GET /api/v4/projects/1234/merge_requests
  Accept: application/json
  Accept-Encoding: gzip
  Private-Token: secret

GET /api/v4/projects/1234/merge_requests/1/versions
  Accept: application/json
  Accept-Encoding: gzip
  Private-Token: secret

GET /api/v4/projects/1234/merge_requests/1/discussions
  Accept: application/json
  Accept-Encoding: gzip
  Private-Token: secret

PUT /api/v4/projects/1234/merge_requests/1/discussions/500
  Accept: application/json
  Accept-Encoding: gzip
  Content-Type: application/json
  Private-Token: secret
--- BODY ---
resolved: true
--- END ---

