Skip to content

Commit

Permalink
Add a test for pint ci with no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Aug 27, 2024
1 parent 9468ff8 commit 180830d
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions cmd/pint/tests/0188_ci_noop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
http response bitbucket /rest/insights/1.0/projects/prometheus/repos/rules/commits/.*/reports/pint 200 OK
http response bitbucket /rest/api/1.0/projects/prometheus/repos/rules/commits/.*/pull-requests 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 .
stderr '{"value":2,"title":"Number of rules parsed","type":"NUMBER"}'
stderr '{"value":2,"title":"Number of rules checked","type":"NUMBER"}'
stderr '{"value":0,"title":"Number of problems found","type":"NUMBER"}'
stderr '{"value":0,"title":"Number of offline checks","type":"NUMBER"}'
stderr '{"value":0,"title":"Number of online checks","type":"NUMBER"}'
stderr '{"value":0,"title":"Checks duration","type":"DURATION"}'

-- 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"
}
}

0 comments on commit 180830d

Please sign in to comment.