@@ -2,6 +2,7 @@ package oncall_test
22
33import (
44 "fmt"
5+ "regexp"
56 "testing"
67
78 onCallAPI "github.com/grafana/amixr-api-go-client"
@@ -46,6 +47,17 @@ func TestAccOnCallOnCallShift_basic(t *testing.T) {
4647 resource .TestCheckResourceAttr ("grafana_oncall_on_call_shift.test-acc-on_call_shift" , "frequency" , "hourly" ),
4748 ),
4849 },
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+ },
4961 {
5062 Config : testAccOnCallOnCallShiftConfigSingle (scheduleName , shiftName ),
5163 Check : resource .ComposeTestCheckFunc (
@@ -113,6 +125,52 @@ resource "grafana_oncall_on_call_shift" "test-acc-on_call_shift" {
113125` , scheduleName , shiftName )
114126}
115127
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+
116174func testAccOnCallOnCallShiftConfigSingle (scheduleName , shiftName string ) string {
117175 return fmt .Sprintf (`
118176resource "grafana_oncall_schedule" "test-acc-schedule" {
0 commit comments