Skip to content

Commit

Permalink
[datadog_synthetics_test] Fix targetvalue for isUndefined json path a…
Browse files Browse the repository at this point in the history
…ssertions (#1966)

* [datadog_synthetics_test] Fix targetvalue for isUndefined json path assertions

* Update go client

* Use enum for operator
  • Loading branch information
romainberger authored Jun 22, 2023
1 parent 358ddf5 commit a4cd676
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 69 deletions.
2 changes: 2 additions & 0 deletions datadog/resource_datadog_synthetics_test_.go
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,8 @@ func buildAssertions(attr []interface{}) []datadogV1.SyntheticsAssertion {
}
if v, ok := targetMap["targetvalue"]; ok {
switch datadogV1.SyntheticsAssertionOperator(operator.(string)) {
case datadogV1.SYNTHETICSASSERTIONOPERATOR_IS_UNDEFINED:
// no target value must be set for isUndefined operator
case
datadogV1.SYNTHETICSASSERTIONOPERATOR_LESS_THAN,
datadogV1.SYNTHETICSASSERTIONOPERATOR_MORE_THAN:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-26T15:45:39.759838-04:00
2023-06-21T15:16:56.147409+02:00

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-26T15:50:00.044869-04:00
2023-06-21T15:54:06.149008+02:00

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion datadog/tests/resource_datadog_synthetics_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ func createSyntheticsAPITestStepNewAssertionsOptions(ctx context.Context, accPro
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "request_client_certificate.0.key.0.filename", "key"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.#", "9"),
"datadog_synthetics_test.bar", "assertion.#", "10"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.0.type", "header"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -1056,6 +1056,16 @@ func createSyntheticsAPITestStepNewAssertionsOptions(ctx context.Context, accPro
"datadog_synthetics_test.bar", "assertion.8.targetxpath.0.operator", "contains"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.8.targetxpath.0.targetvalue", "12"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.9.type", "body"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.9.operator", "validatesJSONPath"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.9.targetjsonpath.#", "1"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.9.targetjsonpath.0.jsonpath", "$.myKey"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "assertion.9.targetjsonpath.0.operator", "isUndefined"),
resource.TestCheckResourceAttr(
"datadog_synthetics_test.bar", "locations.#", "1"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -1205,6 +1215,14 @@ resource "datadog_synthetics_test" "bar" {
xpath = "something"
}
}
assertion {
operator = "validatesJSONPath"
type = "body"
targetjsonpath {
jsonpath = "$.myKey"
operator = "isUndefined"
}
}
locations = [ "aws:eu-central-1" ]
options_list {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/terraform-providers/terraform-provider-datadog

require (
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230616141626-81605366406d
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230620165656-7db2005fda14
github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad
github.com/dnaeon/go-vcr v1.0.1
github.com/hashicorp/go-cleanhttp v0.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230616141626-81605366406d h1:sVyGcGjNGja9DtglbrZzUY2StuRb+60J18oraabJPJI=
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230616141626-81605366406d/go.mod h1:kntOqXEh1SmjwSDzW/eJkr9kS7EqttvEkelglWtJRbg=
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230620165656-7db2005fda14 h1:eZFoAkUM90b3bMPnwSi7G1O3witjsDBPBOM5Z5a258U=
github.com/DataDog/datadog-api-client-go/v2 v2.13.1-0.20230620165656-7db2005fda14/go.mod h1:kntOqXEh1SmjwSDzW/eJkr9kS7EqttvEkelglWtJRbg=
github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down

0 comments on commit a4cd676

Please sign in to comment.