@@ -2,6 +2,7 @@ package oncall_test
2
2
3
3
import (
4
4
"fmt"
5
+ "regexp"
5
6
"testing"
6
7
7
8
onCallAPI "github.com/grafana/amixr-api-go-client"
@@ -46,6 +47,17 @@ func TestAccOnCallOnCallShift_basic(t *testing.T) {
46
47
resource .TestCheckResourceAttr ("grafana_oncall_on_call_shift.test-acc-on_call_shift" , "frequency" , "hourly" ),
47
48
),
48
49
},
50
+ {
51
+ Config : testAccOnCallOnCallShiftEmptyRollingUsers (scheduleName , shiftName ),
52
+ Check : resource .ComposeTestCheckFunc (
53
+ testAccCheckOnCallOnCallShiftResourceExists ("grafana_oncall_on_call_shift.test-acc-on_call_shift" ),
54
+ resource .TestCheckResourceAttr ("grafana_oncall_on_call_shift.test-acc-on_call_shift" , "rolling_users.#" , "0" ),
55
+ ),
56
+ },
57
+ {
58
+ Config : testAccOnCallOnCallShiftRollingUsersEmptyGroup (scheduleName , shiftName ),
59
+ ExpectError : regexp .MustCompile ("Error: `rolling_users` can not include an empty group" ),
60
+ },
49
61
{
50
62
Config : testAccOnCallOnCallShiftConfigSingle (scheduleName , shiftName ),
51
63
Check : resource .ComposeTestCheckFunc (
@@ -113,6 +125,52 @@ resource "grafana_oncall_on_call_shift" "test-acc-on_call_shift" {
113
125
` , scheduleName , shiftName )
114
126
}
115
127
128
+ func testAccOnCallOnCallShiftEmptyRollingUsers (scheduleName , shiftName string ) string {
129
+ return fmt .Sprintf (`
130
+ resource "grafana_oncall_schedule" "test-acc-schedule" {
131
+ type = "calendar"
132
+ name = "%s"
133
+ time_zone = "UTC"
134
+ }
135
+
136
+ resource "grafana_oncall_on_call_shift" "test-acc-on_call_shift" {
137
+ name = "%s"
138
+ type = "rolling_users"
139
+ start = "2020-09-04T16:00:00"
140
+ duration = 3600
141
+ level = 1
142
+ frequency = "weekly"
143
+ week_start = "SU"
144
+ interval = 2
145
+ by_day = ["MO", "FR"]
146
+ rolling_users = []
147
+ }
148
+ ` , scheduleName , shiftName )
149
+ }
150
+
151
+ func testAccOnCallOnCallShiftRollingUsersEmptyGroup (scheduleName , shiftName string ) string {
152
+ return fmt .Sprintf (`
153
+ resource "grafana_oncall_schedule" "test-acc-schedule" {
154
+ type = "calendar"
155
+ name = "%s"
156
+ time_zone = "UTC"
157
+ }
158
+
159
+ resource "grafana_oncall_on_call_shift" "test-acc-on_call_shift" {
160
+ name = "%s"
161
+ type = "rolling_users"
162
+ start = "2020-09-04T16:00:00"
163
+ duration = 3600
164
+ level = 1
165
+ frequency = "weekly"
166
+ week_start = "SU"
167
+ interval = 2
168
+ by_day = ["MO", "FR"]
169
+ rolling_users = [[]]
170
+ }
171
+ ` , scheduleName , shiftName )
172
+ }
173
+
116
174
func testAccOnCallOnCallShiftConfigSingle (scheduleName , shiftName string ) string {
117
175
return fmt .Sprintf (`
118
176
resource "grafana_oncall_schedule" "test-acc-schedule" {
0 commit comments