[v9.3.x] Alerting: Fix integration test for creating silences (#65791)
Alerting: Fix integration test for creating silences (#65722)
* fix integration test for creating silences
to create correct silence with endsAt in the future
* Update api_alertmanager_test.go
(cherry picked from commit ed8628e39d)
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
committed by
GitHub
parent
7e1690b5af
commit
87ca6d206d
@@ -12,11 +12,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||
ngstore "github.com/grafana/grafana/pkg/services/ngalert/store"
|
||||
@@ -208,11 +209,11 @@ func TestIntegrationAMConfigAccess(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("when creating silence", func(t *testing.T) {
|
||||
body := `
|
||||
now := time.Now()
|
||||
body := fmt.Sprintf(`
|
||||
{
|
||||
"comment": "string",
|
||||
"createdBy": "string",
|
||||
"endsAt": "2023-03-31T14:17:04.419Z",
|
||||
"matchers": [
|
||||
{
|
||||
"isRegex": true,
|
||||
@@ -220,9 +221,10 @@ func TestIntegrationAMConfigAccess(t *testing.T) {
|
||||
"value": "string"
|
||||
}
|
||||
],
|
||||
"startsAt": "2021-03-31T13:17:04.419Z"
|
||||
"startsAt": "%s",
|
||||
"endsAt": "%s"
|
||||
}
|
||||
`
|
||||
`, now.Format(time.RFC3339), now.Add(10*time.Second).Format(time.RFC3339))
|
||||
|
||||
testCases := []testCase{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user