Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions cmd/pint/tests/0253_ci_gitlab_invalid_uri.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
mkdir testrepo
cd testrepo
exec git init --initial-branch=main .

exec touch rules.yml
cp ../src/.pint.hcl .
env GIT_AUTHOR_NAME=pint
env [email protected]
env GIT_COMMITTER_NAME=pint
env [email protected]
exec git add .
exec git commit -am 'import rules and config'

exec git checkout -b v2

env GITLAB_AUTH_TOKEN=1
! exec pint -l error --no-color ci
! stdout .
cmp stderr ../stderr.txt

-- stderr.txt --
level=ERROR msg="Execution completed with error(s)" err="failed to create a new GitLab client: failed to parse base URL: parse \"://bad/api/v4/\": missing protocol scheme"
-- src/.pint.hcl --
ci {
baseBranch = "main"
}
repository {
gitlab {
uri = "://bad"
timeout = "30s"
project = "1234"
}
}
35 changes: 35 additions & 0 deletions cmd/pint/tests/0254_ci_github_invalid_uri.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
mkdir testrepo
cd testrepo
exec git init --initial-branch=main .

exec touch rules.yml
cp ../src/.pint.hcl .
env GIT_AUTHOR_NAME=pint
env [email protected]
env GIT_COMMITTER_NAME=pint
env [email protected]
exec git add .
exec git commit -am 'import rules and config'

exec git checkout -b v2

env GITHUB_AUTH_TOKEN=1
env GITHUB_PULL_REQUEST_NUMBER=1
env GITHUB_ACTION=1
env GITHUB_API_URL=://bad
! exec pint -l error --no-color ci
! stdout .
cmp stderr ../stderr.txt

-- stderr.txt --
level=ERROR msg="Execution completed with error(s)" err="creating new GitHub client: parse \"://bad\": missing protocol scheme"
-- src/.pint.hcl --
ci {
baseBranch = "main"
}
repository {
github {
owner = "cloudflare"
repo = "pint"
}
}
19 changes: 19 additions & 0 deletions cmd/pint/tests/0255_lint_checkstyle_write_error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
! exec pint --no-color lint --checkstyle=/dev/full rules
! stdout .
cmp stderr stderr.txt

-- stderr.txt --
level=INFO msg="Finding all rules to check" paths=["rules"]
level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true
Warning: always firing alert (alerts/comparison)
---> rules/0001.yml:5 -> `foo`
5 | expr: up
^^ This query doesn't have any condition and so this alert will always fire if it matches anything.

level=ERROR msg="Execution completed with error(s)" err="submitting reports: write /dev/full: no space left on device"
-- rules/0001.yml --
groups:
- name: foo
rules:
- alert: foo
expr: up
33 changes: 33 additions & 0 deletions internal/promapi/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,39 @@ func TestQuery(t *testing.T) {
UnlimitedTimes()
}),
},
{
name: "badMetricKind",
timeout: time.Second,
err: `bad_response: JSON parse error: json: cannot unmarshal JSON array into Go promapi.SampleLabels within "/data/result/0/metric"`,
mock: httpmock.New(func(s *httpmock.Server) {
s.ExpectPost(promapi.APIPathQuery).
ReturnHeader("Content-Type", "application/json").
Return(`{"status":"success","data":{"resultType":"vector","result":[{"metric":[],"value":[1614859502.068,"1"]}]}}`).
UnlimitedTimes()
}),
},
{
name: "badValueKind",
timeout: time.Second,
err: `bad_response: JSON parse error: json: cannot unmarshal JSON object into Go promapi.SampleTimestampValue within "/data/result/0/value"`,
mock: httpmock.New(func(s *httpmock.Server) {
s.ExpectPost(promapi.APIPathQuery).
ReturnHeader("Content-Type", "application/json").
Return(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{},"value":{}}]}}`).
UnlimitedTimes()
}),
},
{
name: "badValueClosingToken",
timeout: time.Second,
err: `bad_response: JSON parse error: json: cannot unmarshal JSON object into Go promapi.SampleTimestampValue within "/data/result/0/value"`,
mock: httpmock.New(func(s *httpmock.Server) {
s.ExpectPost(promapi.APIPathQuery).
ReturnHeader("Content-Type", "application/json").
Return(`{"status":"success","data":{"resultType":"vector","result":[{"metric":{},"value":{"ts":1}}]}}`).
UnlimitedTimes()
}),
},
}

for _, tc := range testCases {
Expand Down
Loading