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 []
http method gitlab GET /api/v4/projects/1234/merge_requests 200 [{"iid": 1}]
http method gitlab POST /api/v4/projects/1234/merge_requests/1/discussions 200 {}
http start gitlab 127.0.0.1:6213

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 .
cmp gitlab.got ../gitlab.expected

-- src/v1.yml --
groups:
- name: foo
  rules:
  - record: rule1
    expr: sum(foo) by(job)
  - record: rule2
    expr: sum(rule1) by(job)

-- src/v2.yml --
groups:
- name: foo
  rules:
  - record: rule3
    expr: sum(foo) by(job)
  - record: rule2
    expr: sum(rule1) by(job)

-- src/.pint.hcl --
ci {
  baseBranch = "main"
}
repository {
  gitlab {
    uri        = "http://127.0.0.1:6213"
    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

POST /api/v4/projects/1234/merge_requests/1/discussions
  Accept: application/json
  Accept-Encoding: gzip
  Content-Type: application/json
  Private-Token: secret
--- BODY ---
body: |
  :warning: **Warning** reported by [pint](https://cloudflare.github.io/pint/) **rule/dependency** check.

  ------

  rule results used by another rule

  <details>
  <summary>More information</summary>
  If you remove the recording rule generating `rule1`, and there is no other source of this metric, then any other rule depending on it will break.
  List of found rules that are using `rule1`:

  - `rule2` at `rules.yml:7`

  </details>

  ------

  :information_source: To see documentation covering this check and instructions on how to resolve it [click here](https://cloudflare.github.io/pint/checks/rule/dependency.html).
position:
  base_sha: base
  head_sha: head
  start_sha: start
  new_path: rules.yml
  old_path: rules.yml
  position_type: text
  old_line: 4
--- END ---

