From 180830d8eb5b1e4929c7011e48fdd84b013190ce Mon Sep 17 00:00:00 2001 From: Lukasz Mierzwa Date: Tue, 27 Aug 2024 11:55:50 +0100 Subject: [PATCH] Add a test for pint ci with no changes --- cmd/pint/tests/0188_ci_noop.txt | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 cmd/pint/tests/0188_ci_noop.txt diff --git a/cmd/pint/tests/0188_ci_noop.txt b/cmd/pint/tests/0188_ci_noop.txt new file mode 100644 index 00000000..dd977382 --- /dev/null +++ b/cmd/pint/tests/0188_ci_noop.txt @@ -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" + } +}