File size: 1,134 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package smoke

import (
	"fmt"
	"testing"

	"github.com/target/goalert/test/smoke/harness"
)

// TestDeleteRotation tests that it is possible to delete a rotation with participants
func TestDeleteRotation(t *testing.T) {
	t.Parallel()

	const sql = `
	insert into users (id, name, email, role)
	values
		({{uuid "u1"}}, 'bob', 'joe', 'user'),
		({{uuid "u2"}}, 'ben', 'josh', 'user');
	
	insert into rotations (id, name, description, type, start_time, time_zone)
	values
		({{uuid "r1"}}, 'test', 'test', 'daily', now(), 'UTC');
	
	insert into rotation_participants (id, rotation_id, user_id, position)
	values
		({{uuid ""}}, {{uuid "r1"}}, {{uuid "u1"}},0),
		({{uuid ""}}, {{uuid "r1"}}, {{uuid "u2"}},1);
`

	h := harness.NewHarness(t, sql, "heartbeats")
	defer h.Close()

	doQL := func(query string) {
		g := h.GraphQLQuery2(query)
		for _, err := range g.Errors {
			t.Error("GraphQL Error:", err.Message)
		}
		if len(g.Errors) > 0 {
			t.Fatal("errors returned from GraphQL")
		}
		t.Log("Response:", string(g.Data))
	}

	doQL(fmt.Sprintf(`
		mutation {
			deleteAll(input:{id: "%s", type: rotation})
		}
	`, h.UUID("r1")))
}