mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix flaky test (#55551)
The length of the identifier from the underlying library is 9 or more characters depending on the rate at which the identifiers are generated. See https://pkg.go.dev/github.com/teris-io/shortid The test previously made the assumption that the length will always be 10, which would intermittently fail.
This commit is contained in:
parent
7b4cea8151
commit
647997cc4c
@ -110,8 +110,10 @@ func TestMakeAlertRule(t *testing.T) {
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Len(t, ar.Title, DefaultFieldMaxLength)
|
||||
uniq := ar.Title[len(ar.Title)-11:]
|
||||
require.Regexp(t, "^_.{10}$", uniq)
|
||||
parts := strings.SplitN(ar.Title, "_", 2)
|
||||
require.Len(t, parts, 2)
|
||||
require.Greater(t, len(parts[1]), 8, "unique identifier should be longer than 9 characters")
|
||||
require.Equal(t, DefaultFieldMaxLength-1, len(parts[0])+len(parts[1]), "truncated name + underscore + unique identifier should together be DefaultFieldMaxLength")
|
||||
require.Equal(t, ar.Title, ar.RuleGroup)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user