http response bitbucket /plugins/servlet/applinks/whoami 200 pint
http response bitbucket /rest/api/1.0/projects/prometheus/repos/rules/commits/.*/pull-requests 200 {"size":1,"isLastPage":true,"values":[{"id":1,"open":true,"fromRef":{"id":"refs/heads/v2","latestCommit":"fake-commit-id"},"toRef":{"id":"refs/heads/main","latestCommit":"fake-commit-id"}}]}
http response bitbucket /rest/api/latest/projects/prometheus/repos/rules/pull-requests/1/activities 200 {"size":0,"isLastPage":true,"values":[]}
http response bitbucket /rest/api/1.0/projects/prometheus/repos/rules/pull-requests/1/comments 200 {}
http start bitbucket 127.0.0.1:6188

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

cp ../src/rules.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
exec touch .keep
exec git add .keep
exec git commit -am 'v2'

env BITBUCKET_AUTH_TOKEN="12345"
exec pint -l debug --no-color ci
! stdout .
cmp bitbucket.got ../bitbucket.expected

-- src/rules.yml --
- alert: alert1
  expr: up == 0
  for: 5m
- alert: alert2
  expr: up == 0
  for: 5m

-- src/.pint.hcl --
parser {
  relaxed = [".*"]
}
ci {
  baseBranch = "main"
}
repository {
  bitbucket {
    uri        = "http://127.0.0.1:6188"
    project    = "prometheus"
    repository = "rules"
  }
}
prometheus "prom" {
  uri      = "http://127.0.0.1:2188"
  timeout  = "5s"
  required = true
}
rule {
  match {
    kind = "alerting"
  }
  alerts {
    range      = "1d"
    step       = "1m"
    resolve    = "5m"
  }
}

-- bitbucket.expected --
GET /rest/api/1.0/projects/prometheus/repos/rules/commits/.*/pull-requests
  Accept-Encoding: gzip
  Authorization: Bearer "12345"
  Content-Type: application/json

GET /plugins/servlet/applinks/whoami
  Accept-Encoding: gzip
  Authorization: Bearer "12345"
  Content-Type: application/json

GET /rest/api/latest/projects/prometheus/repos/rules/pull-requests/1/activities
  Accept-Encoding: gzip
  Authorization: Bearer "12345"
  Content-Type: application/json

