Skip to content

Commit

Permalink
FFM-1082 Update test for stopTime
Browse files Browse the repository at this point in the history
  • Loading branch information
pdoshisplunk committed Aug 29, 2024
1 parent 6d176ab commit 72724ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions signalfx/resource_signalfx_metric_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ func getRestoration(tfRule map[string]interface{}) metric_ruleset.ExceptionRuleR
panic(err)
}

stopTime, err := strconv.ParseInt(restoration["stop_time"].(string), 10, 64)
if err != nil {
panic(err)
stopTime, err1 := strconv.ParseInt(restoration["stop_time"].(string), 10, 64)
if err1 != nil {
panic(err1)
}

restorationFields := &metric_ruleset.ExceptionRuleRestorationFields{
Expand Down
9 changes: 7 additions & 2 deletions signalfx/resource_signalfx_metric_ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ func TestAccMetricRulesetArchived(t *testing.T) {
func TestAccMetricRulesetRestoration(t *testing.T) {
// 15 minutes ago in milliseconds
startTime := (time.Now().Unix() - 900) * 1000
stopTime := (time.Now().Unix() - 200) * 1000

archivedCartSizeRestore := fmt.Sprintf(`
resource "signalfx_metric_ruleset" "cart_size" {
Expand All @@ -487,13 +488,14 @@ resource "signalfx_metric_ruleset" "cart_size" {
}
restoration {
start_time = %d
stop_time = %d
}
}
routing_rule {
destination = "Archived"
}
} `, startTime)
} `, startTime, stopTime)

archivedCartSizeRestoreUpdate := fmt.Sprintf(`
resource "signalfx_metric_ruleset" "cart_size" {
Expand All @@ -512,13 +514,14 @@ resource "signalfx_metric_ruleset" "cart_size" {
}
restoration {
start_time = %d
stop_time = %d
}
}
routing_rule {
destination = "Archived"
}
} `, startTime)
} `, startTime, stopTime)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -550,6 +553,7 @@ resource "signalfx_metric_ruleset" "cart_size" {
resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.matcher.0.filters.0.not", "false"),

resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.restoration.0.start_time", strconv.FormatInt(startTime, 10)),
resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.restoration.0.stop_time", strconv.FormatInt(stopTime, 10)),
),
},
// Validate plan
Expand Down Expand Up @@ -578,6 +582,7 @@ resource "signalfx_metric_ruleset" "cart_size" {
resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.matcher.0.filters.0.not", "false"),

resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.restoration.0.start_time", strconv.FormatInt(startTime, 10)),
resource.TestCheckResourceAttr("signalfx_metric_ruleset.cart_size", "exception_rules.0.restoration.0.stop_time", strconv.FormatInt(stopTime, 10)),
),
},
},
Expand Down

0 comments on commit 72724ec

Please sign in to comment.