add test coverage for updateCheck mutations
@@ -9,12 +9,12 @@ import (
"golang.org/x/net/context"
)
-type CreateCheckMutationSuite struct {
+type CheckMutationSuite struct {
suite.Suite
mutationSuite
}
-func (t *CreateCheckMutationSuite) SetupTest() {
+func (t *CheckMutationSuite) SetupTest() {
// Ensure query is run with viwer that has full access.
t.populateContext(contextWithFullAccess)
@@ -25,7 +25,7 @@ func (t *CreateCheckMutationSuite) SetupTest() {
})
}
-func (t *CreateCheckMutationSuite) TestSuccess() {
+func (t *CheckMutationSuite) TestCreateSuccess() {
result, errs := t.runQuery(
t.T(),
`
@@ -49,10 +49,42 @@ func (t *CreateCheckMutationSuite) TestSuccess() {
)
t.Empty(errs)
- t.Equal(result.Get("createCheck", "check", "name"), "my-check")
+ t.Equal("my-check", result.Get("createCheck", "check", "name"))
}
-func (t *CreateCheckMutationSuite) TestInvalidInputs() {
+func (t *CheckMutationSuite) TestUpdateSuccess() {
+ t.populateStore(func(ctx context.Context, st store.Store) {
+ st.UpdateCheckConfig(ctx, types.FixtureCheckConfig("my-check"))
+ })
+
+ result, errs := t.runQuery(
+ t.T(),
+ `
+ mutation myMutation($inputs: UpdateCheckInput!) {
+ updateCheck(input: $inputs) {
+ check {
+ name
+ interval
+ }
+ }
+ }
+ `,
+ map[string]interface{}{
+ "inputs": map[string]interface{}{
+ "clientMutationId": "1",
+ "name": "my-check",
+ "organization": "default",
+ "environment": "default",
+ "interval": 30,
+ },
+ },
+ )
+
+ t.Empty(errs)
+ t.Equal(30, result.Get("updateCheck", "check", "interval"))
+}
+
+func (t *CheckMutationSuite) TestCreateInvalidInputs() {
result, errs := t.runQuery(
t.T(),
`
@@ -79,9 +111,36 @@ func (t *CreateCheckMutationSuite) TestInvalidInputs() {
t.Nil(result.Get("createCheck"))
}
+func (t *CheckMutationSuite) TestUpdateInvalidInputs() {
+ result, errs := t.runQuery(
+ t.T(),
+ `
+ mutation myMutation($inputs: UpdateCheckInput!) {
+ updateCheck(input: $inputs) {
+ check {
+ name
+ }
+ }
+ }
+ `,
+ map[string]interface{}{
+ "inputs": map[string]interface{}{
+ "clientMutationId": "1",
+ "name": "my-check",
+ "organization": "badorg",
+ "environment": "very-bad-env",
+ "interval": 0,
+ },
+ },
+ )
+
+ t.NotEmpty(errs)
+ t.Nil(result.Get("updateCheck"))
+}
+
func TestCheckMutations(testRunner *testing.T) {
runSuites(
testRunner,
- new(CreateCheckMutationSuite),
+ new(CheckMutationSuite),
)
}
