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

Commit

Permalink
Add update test steps to different monitor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louy committed Apr 16, 2019
1 parent cc8f147 commit 7ca8e23
Showing 1 changed file with 57 additions and 53 deletions.
110 changes: 57 additions & 53 deletions uptimerobot/resource_uptimerobot_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestUptimeRobotDataResourceMonitor_http_monitor(t *testing.T) {
var FriendlyName = "TF Test: http monitor"
var Type = "http"
var URL = "https://google.com"
var URL2 = "https://yahoo.com"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -39,6 +40,23 @@ func TestUptimeRobotDataResourceMonitor_http_monitor(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
}
`, FriendlyName, Type, URL2),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL2),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -48,6 +66,7 @@ func TestUptimeRobotDataResourceMonitor_keyword_monitor(t *testing.T) {
var Type = "keyword"
var URL = "https://google.com"
var KeywordType = "not exists"
var KeywordType2 = "exists"
var KeywordValue = "yahoo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -77,6 +96,25 @@ func TestUptimeRobotDataResourceMonitor_keyword_monitor(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
keyword_type = "%s"
keyword_value = "%s"
}
`, FriendlyName, Type, URL, KeywordType2, KeywordValue),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "keyword_type", KeywordType2),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -85,6 +123,7 @@ func TestUptimeRobotDataResourceMonitor_http_port_monitor(t *testing.T) {
var FriendlyName = "TF Test: http port monitor"
var Type = "port"
var URL = "google.com"
var URL2 = "yahoo.com"
var SubType = "http"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -112,6 +151,24 @@ func TestUptimeRobotDataResourceMonitor_http_port_monitor(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
sub_type = "%s"
}
`, FriendlyName, Type, URL2, SubType),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL2),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -237,59 +294,6 @@ func TestUptimeRobotDataResourceMonitor_custom_http_headers(t *testing.T) {
})
}

func TestUptimeRobotDataResourceMonitor_change_url(t *testing.T) {
var FriendlyName = "TF Test: change url"
var Type = "http"
var URL = "https://google.com"
var URL2 = "https://google.co.uk"
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,
},
// Change url
resource.TestStep{
Config: fmt.Sprintf(`
resource "uptimerobot_monitor" "test" {
friendly_name = "%s"
type = "%s"
url = "%s"
}
`, FriendlyName, Type, URL2),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "friendly_name", FriendlyName),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "type", Type),
resource.TestCheckResourceAttr("uptimerobot_monitor.test", "url", URL2),
),
},
resource.TestStep{
ResourceName: "uptimerobot_monitor.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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

0 comments on commit 7ca8e23

Please sign in to comment.