Skip to content
Draft
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
20 changes: 11 additions & 9 deletions grafana-alertcheck/internal/gate/duration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ func TestParsePromDuration(t *testing.T) {

func TestParsePromDuration_Errors(t *testing.T) {
cases := []string{
"5", // bare number, no unit
"-5m", // negative
"5x", // unknown unit
"30m1h", // ascending order (must be descending)
"1h1h", // duplicate unit
"m", // unit with no number
"1.5h", // fractional number not supported by this grammar
"1 h", // whitespace
"300y", // overflows time.Duration (int64 nanoseconds) — must error, not wrap negative
"5", // bare number, no unit
"-5m", // negative
"5x", // unknown unit
"30m1h", // ascending order (must be descending)
"1h1h", // duplicate unit
"m", // unit with no number
"1.5h", // fractional number not supported by this grammar
"1 h", // whitespace
"300y", // overflows time.Duration (int64 nanoseconds) — must error, not wrap negative
"1w2d3h4m5s6ms7us8ns", // too many units
"carrot", // completely invalid
}
for _, in := range cases {
if _, err := ParsePromDuration(in); err == nil {
Expand Down
Loading
Loading