Skip to content

Commit

Permalink
SYN-4410: Do not send 0 for max_wait_time if field is not provided (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
sangn-splunk authored Oct 10, 2024
1 parent 9cbc8fb commit ddbe58e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions synthetics/resource_browser_check_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ func resourceBrowserCheckV2() *schema.Resource {
"max_wait_time": {
Type: schema.TypeInt,
Optional: true,
Default: 10000,
ValidateFunc: validation.IntAtLeast(1),
},
"options": {
Type: schema.TypeSet,
Expand Down
17 changes: 14 additions & 3 deletions synthetics/resource_browser_check_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
selector_type = "id"
type = "select_option"
wait_for_nav = false
wait_for_nav_timeout = 0
wait_for_nav_timeout = 1
}
}
transactions {
Expand All @@ -140,6 +140,12 @@ resource "synthetics_create_browser_check_v2" "browser_v2_foo_check" {
selector_type = "id"
max_wait_time = 1000
}
steps {
name = "assert element visible no max wait time"
type = "assert_element_visible"
selector = "beep"
selector_type = "id"
}
}
}
}
Expand Down Expand Up @@ -344,7 +350,7 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.2.selector_type", "id"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.2.type", "click_element"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.2.wait_for_nav", "true"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.2.wait_for_nav_timeout", "2000"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.2.wait_for_nav_timeout", "50"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.3.name", "04 accept---Alert"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.3.type", "accept_alert"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.name", "05 Select-val-text"),
Expand All @@ -354,7 +360,7 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.selector_type", "id"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.type", "select_option"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.wait_for_nav", "false"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.wait_for_nav_timeout", "50"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.0.steps.4.wait_for_nav_timeout", "1"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.name", "2nd Synthetic transaction"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.0.name", "Go to other URL"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.0.type", "go_to_url"),
Expand All @@ -370,6 +376,11 @@ func TestAccCreateUpdateBrowserCheckV2(t *testing.T) {
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.2.selector", "beep"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.2.selector_type", "id"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.2.max_wait_time", "1000"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.3.name", "assert element visible no max wait time"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.3.type", "assert_element_visible"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.3.selector", "beep"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.3.selector_type", "id"),
resource.TestCheckResourceAttr("synthetics_create_browser_check_v2.browser_v2_foo_check", "test.0.transactions.1.steps.3.max_wait_time", "10000"),
),
},
{
Expand Down
4 changes: 3 additions & 1 deletion synthetics/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,9 @@ func flattenStepsData(checkSteps *[]sc2.StepsV2) []interface{} {

if checkStep.MaxWaitTime != 0 {
cl["max_wait_time"] = checkStep.MaxWaitTime
}
} else {
cl["max_wait_time"] = 10000
}

if checkStep.Selector != "" {
cl["selector"] = checkStep.Selector
Expand Down

0 comments on commit ddbe58e

Please sign in to comment.