Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add test for custom interval
Browse files Browse the repository at this point in the history
  • Loading branch information
louy committed Aug 27, 2018
1 parent 3cf611e commit 39ed5df
Showing 1 changed file with 93 additions and 2 deletions.
95 changes: 93 additions & 2 deletions uptimerobot/resource_uptimerobot_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@ import (
)

func TestUptimeRobotDataResourceMonitor_http_monitor(t *testing.T) {
var FriendlyName = "TF Test: http monitor"
var Type = "http"
var URL = "https://google.com"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitorDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
}
`, FriendlyName, Type, URL),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "friendly_name", FriendlyName),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "type", Type),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestUptimeRobotDataResourceMonitor_change_url(t *testing.T) {
var FriendlyName = "TF Test: http monitor"
var Type = "http"
var URL = "https://google.com"
Expand All @@ -23,7 +55,8 @@ func TestUptimeRobotDataResourceMonitor_http_monitor(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" { friendly_name = "%s"
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
}
Expand All @@ -42,7 +75,8 @@ func TestUptimeRobotDataResourceMonitor_http_monitor(t *testing.T) {
// Change url
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" { friendly_name = "%s"
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
}
Expand Down Expand Up @@ -94,6 +128,63 @@ func TestUptimeRobotDataResourceMonitor_ping_monitor(t *testing.T) {
})
}

func TestUptimeRobotDataResourceMonitor_custom_interval(t *testing.T) {
var FriendlyName = "TF Test: ping monitor"
var Type = "ping"
var URL = "1.1.1.1"
var Interval = 300
var Interval2 = 360
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckMonitorDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
interval = %d
}
`, FriendlyName, Type, URL, Interval),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "friendly_name", FriendlyName),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "type", Type),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "interval", fmt.Sprintf(`%d`, Interval)),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
interval = %d
}
`, FriendlyName, Type, URL, Interval2),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "friendly_name", FriendlyName),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "type", Type),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "interval", fmt.Sprintf(`%d`, Interval2)),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestUptimeRobotDataResourceMonitor_http_auth_monitor(t *testing.T) {
var FriendlyName = "TF Test: http auth monitor"
var Type = "http"
Expand Down

0 comments on commit 39ed5df

Please sign in to comment.