http response prometheus /api/v1/status/flags 200 {"status":"success","data":{"storage.tsdb.retention.time": "1d"}}
http response prometheus /api/v1/metadata 200 {"status":"success","data":{}}
http response prometheus /api/v1/status/config 200 {"status":"success","data":{"yaml":"global:\n  scrape_interval: 1m\n"}}
http response prometheus /api/v1/query_range 200 {"status":"success","data":{"resultType":"matrix","result":[]}}
http response prometheus /api/v1/query 200 {"status":"success","data":{"resultType":"vector","result":[]}}
http start prometheus 127.0.0.1:2100

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:6100

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 BITBUCKET_AUTH_TOKEN="12345"
exec pint -l debug --no-color ci
! stdout .
cmp bitbucket.got ../bitbucket.expected

-- src/v1.yml --
- alert: alert1
  # pint disable promql/series(prom)
  expr: up == 0
  for: 5m
- alert: alert2
  # pint disable promql/series(prom)
  expr: up == 0
  for: 5m
-- src/v2.yml --
- alert: alert1
  # pint disable promql/series(prom)
  expr: |
    up{job="foo"} == 0
  for: 5m
- alert: alert2
  # pint disable promql/series(prom)
  expr: |
    up{job="foo"}
    ==
    0
  for: 1m

-- src/.pint.hcl --
parser {
  relaxed = [".*"]
}
ci {
  baseBranch = "main"
}
repository {
  bitbucket {
    uri        = "http://127.0.0.1:6100"
    project    = "prometheus"
    repository = "rules"
  }
}
prometheus "prom" {
  uri      = "http://127.0.0.1:2100"
  timeout  = "5s"
  required = true
}
rule {
  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

POST /rest/api/1.0/projects/prometheus/repos/rules/pull-requests/1/comments
  Accept-Encoding: gzip
  Authorization: Bearer "12345"
  Content-Type: application/json
--- BODY ---
text: |
    :information_source: **Information** reported by [pint](https://cloudflare.github.io/pint/) **alerts/count** check.

    <details>
    <summary>alert count estimate</summary>

    ```yaml
    4 |     up{job="foo"} == 0
            ^^^^^^^^^^^^^^^^^^
    ```

    `prom` Prometheus server at http://127.0.0.1:2100 would trigger 0 alert(s) in the last 1d.

    To get a preview of the alerts that would fire please [click here](http://127.0.0.1:2100/graph?g0.expr=up%7Bjob%3D%22foo%22%7D+%3D%3D+0%0A&g0.tab=0&g0.range_input=1d).

    </details>

    ------

    The same issue was reported 1 more time(s), duplicates were suppressed.

    <details>
    <summary>Show affected rules</summary>

    - `alert2` at `rules.yml:9`

    </details>

    ------

    :information_source: To see documentation covering this check and instructions on how to resolve it [click here](https://cloudflare.github.io/pint/checks/alerts/count.html).
severity: NORMAL
anchor:
    path: rules.yml
    lineType: ADDED
    fileType: TO
    diffType: EFFECTIVE
    line: 4
--- END ---

