-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cart_discount): Added support for totalPrice target on cart_disc…
…ount resource
- Loading branch information
1 parent
748eef5
commit ba44c99
Showing
6 changed files
with
106 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kind: Fixed | ||
body: Added support for totalPrice target on cart_discount resource | ||
time: 2024-01-19T11:54:29.492858858+01:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package commercetools | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccCartDiscountTotalPrice(t *testing.T) { | ||
identifier := "totalPrice" | ||
resourceName := "commercetools_cart_discount.totalPrice" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviders, | ||
CheckDestroy: testAccCheckCartDiscountDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCartDiscountTotalPriceConfig(identifier), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "name.en", "absolute name"), | ||
resource.TestCheckResourceAttr(resourceName, "value.0.type", "absolute"), | ||
resource.TestCheckResourceAttr(resourceName, "value.0.money.0.currency_code", "USD"), | ||
resource.TestCheckResourceAttr(resourceName, "value.0.money.0.cent_amount", "1000"), | ||
resource.TestCheckResourceAttr(resourceName, "value.0.money.1.currency_code", "EUR"), | ||
resource.TestCheckResourceAttr(resourceName, "value.0.money.1.cent_amount", "2000"), | ||
resource.TestCheckResourceAttr(resourceName, "target.0.type", "totalPrice"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCartDiscountTotalPriceConfig(identifier string) string { | ||
return hclTemplate(` | ||
resource "commercetools_cart_discount" "{{ .identifier }}" { | ||
name = { | ||
en = "absolute name" | ||
} | ||
sort_order = "0.9" | ||
predicate = "1=1" | ||
target { | ||
type = "totalPrice" | ||
} | ||
value { | ||
type = "absolute" | ||
money { | ||
currency_code = "USD" | ||
cent_amount = 1000 | ||
} | ||
money { | ||
currency_code = "EUR" | ||
cent_amount = 2000 | ||
} | ||
} | ||
} | ||
`, map[string]any{ | ||
"identifier": identifier, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters