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
This commit is contained in:
Yuri Tseretyan 2023-03-31 11:44:05 -04:00 committed by GitHub
parent a24554ba0a
commit ed8628e39d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"
@ -212,11 +213,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,
@ -224,9 +225,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{
{