|
|
|
|
@ -51,6 +51,52 @@ func TestAccPagerDutySchedule_Basic(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccPagerDutySchedule_BasicWeek(t *testing.T) {
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckPagerDutyScheduleDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccCheckPagerDutyScheduleConfigWeek,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckPagerDutyScheduleExists("pagerduty_schedule.foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "name", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "description", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "time_zone", "Europe/Berlin"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.name", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.restriction.0.start_day_of_week", "1"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccCheckPagerDutyScheduleConfigWeekUpdated,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckPagerDutyScheduleExists("pagerduty_schedule.foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "name", "bar"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "description", "Managed by Terraform"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "time_zone", "America/New_York"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.name", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.restriction.0.start_day_of_week", "5"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccPagerDutySchedule_Multi(t *testing.T) {
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
@ -67,14 +113,57 @@ func TestAccPagerDutySchedule_Multi(t *testing.T) {
|
|
|
|
|
"pagerduty_schedule.foo", "description", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "time_zone", "America/New_York"),
|
|
|
|
|
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.#", "3"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.name", "foo"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.restriction.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.restriction.0.duration_seconds", "32101"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.restriction.0.start_time_of_day", "08:00:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.rotation_turn_length_seconds", "86400"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.rotation_virtual_start", "2015-11-06T20:00:00-05:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.0.users.#", "1"),
|
|
|
|
|
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.name", "bar"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.restriction.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.restriction.0.duration_seconds", "32101"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.restriction.0.start_time_of_day", "08:00:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.restriction.0.start_day_of_week", "5"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.rotation_turn_length_seconds", "86400"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.rotation_virtual_start", "2015-11-06T20:00:00-05:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.1.users.#", "1"),
|
|
|
|
|
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.name", "foobar"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.restriction.#", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.restriction.0.duration_seconds", "32101"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.restriction.0.start_time_of_day", "08:00:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.restriction.0.start_day_of_week", "1"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.rotation_turn_length_seconds", "86400"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.rotation_virtual_start", "2015-11-06T20:00:00-05:00"),
|
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
|
"pagerduty_schedule.foo", "layer.2.users.#", "1"),
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
@ -178,6 +267,63 @@ resource "pagerduty_schedule" "foo" {
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccCheckPagerDutyScheduleConfigWeek = `
|
|
|
|
|
resource "pagerduty_user" "foo" {
|
|
|
|
|
name = "foo"
|
|
|
|
|
email = "foo@bar.com"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "pagerduty_schedule" "foo" {
|
|
|
|
|
name = "foo"
|
|
|
|
|
|
|
|
|
|
time_zone = "Europe/Berlin"
|
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
|
|
layer {
|
|
|
|
|
name = "foo"
|
|
|
|
|
start = "2015-11-06T20:00:00-05:00"
|
|
|
|
|
rotation_virtual_start = "2015-11-06T20:00:00-05:00"
|
|
|
|
|
rotation_turn_length_seconds = 86400
|
|
|
|
|
users = ["${pagerduty_user.foo.id}"]
|
|
|
|
|
|
|
|
|
|
restriction {
|
|
|
|
|
type = "weekly_restriction"
|
|
|
|
|
start_time_of_day = "08:00:00"
|
|
|
|
|
start_day_of_week = 1
|
|
|
|
|
duration_seconds = 32101
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccCheckPagerDutyScheduleConfigWeekUpdated = `
|
|
|
|
|
resource "pagerduty_user" "foo" {
|
|
|
|
|
name = "foo"
|
|
|
|
|
email = "foo@bar.com"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "pagerduty_schedule" "foo" {
|
|
|
|
|
name = "bar"
|
|
|
|
|
|
|
|
|
|
time_zone = "America/New_York"
|
|
|
|
|
|
|
|
|
|
layer {
|
|
|
|
|
name = "foo"
|
|
|
|
|
start = "2015-11-06T20:00:00-05:00"
|
|
|
|
|
rotation_virtual_start = "2015-11-06T20:00:00-05:00"
|
|
|
|
|
rotation_turn_length_seconds = 86400
|
|
|
|
|
users = ["${pagerduty_user.foo.id}"]
|
|
|
|
|
|
|
|
|
|
restriction {
|
|
|
|
|
type = "weekly_restriction"
|
|
|
|
|
start_time_of_day = "08:00:00"
|
|
|
|
|
start_day_of_week = 5
|
|
|
|
|
duration_seconds = 32101
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccCheckPagerDutyScheduleConfigMulti = `
|
|
|
|
|
resource "pagerduty_user" "foo" {
|
|
|
|
|
name = "foo"
|
|
|
|
|
@ -212,8 +358,9 @@ resource "pagerduty_schedule" "foo" {
|
|
|
|
|
users = ["${pagerduty_user.foo.id}"]
|
|
|
|
|
|
|
|
|
|
restriction {
|
|
|
|
|
type = "daily_restriction"
|
|
|
|
|
type = "weekly_restriction"
|
|
|
|
|
start_time_of_day = "08:00:00"
|
|
|
|
|
start_day_of_week = 5
|
|
|
|
|
duration_seconds = 32101
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -226,8 +373,9 @@ resource "pagerduty_schedule" "foo" {
|
|
|
|
|
users = ["${pagerduty_user.foo.id}"]
|
|
|
|
|
|
|
|
|
|
restriction {
|
|
|
|
|
type = "daily_restriction"
|
|
|
|
|
type = "weekly_restriction"
|
|
|
|
|
start_time_of_day = "08:00:00"
|
|
|
|
|
start_day_of_week = 1
|
|
|
|
|
duration_seconds = 32101
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|