-
-
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.
Merge remote-tracking branch 'origin/main' into 529-add-support-for-p…
…roject-productsearchindexingmode # Conflicts: # go.mod
- Loading branch information
Showing
6 changed files
with
143 additions
and
1 deletion.
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: Added | ||
body: Added stores to cart discounts | ||
time: 2024-10-22T16:27:37.948019802+02: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,100 @@ | ||
package commercetools | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccCartDiscountStores(t *testing.T) { | ||
identifier := "stores" | ||
resourceName := "commercetools_cart_discount.stores" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: testAccProviders, | ||
CheckDestroy: testAccCheckCartDiscountDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCartDiscountWithoutStores(identifier), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "stores.#", "0"), | ||
), | ||
}, | ||
{ | ||
Config: testAccCartDiscountWithStores(identifier), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckTypeSetElemAttr(resourceName, "stores.*", "my-store"), | ||
), | ||
}, | ||
{ | ||
Config: testAccCartDiscountWithoutStores(identifier), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(resourceName, "stores.#", "0"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCartDiscountWithoutStores(identifier string) string { | ||
return hclTemplate(` | ||
resource "commercetools_cart_discount" "{{ .identifier }}" { | ||
name = { | ||
en = "fixed name" | ||
} | ||
sort_order = "0.9" | ||
predicate = "1=1" | ||
target { | ||
type = "shipping" | ||
} | ||
value { | ||
type = "fixed" | ||
money { | ||
currency_code = "USD" | ||
cent_amount = 1000 | ||
} | ||
} | ||
} | ||
`, map[string]any{ | ||
"identifier": identifier, | ||
}) | ||
} | ||
|
||
func testAccCartDiscountWithStores(identifier string) string { | ||
return hclTemplate(` | ||
resource "commercetools_store" "my-store-{{ .identifier }}" { | ||
key = "my-store" | ||
name = { | ||
en-US = "My store" | ||
} | ||
countries = ["NL", "BE"] | ||
languages = ["nl-NL"] | ||
} | ||
resource "commercetools_cart_discount" "{{ .identifier }}" { | ||
name = { | ||
en = "fixed name" | ||
} | ||
stores = [commercetools_store.my-store-{{ .identifier }}.key] | ||
sort_order = "0.9" | ||
predicate = "1=1" | ||
target { | ||
type = "shipping" | ||
} | ||
value { | ||
type = "fixed" | ||
money { | ||
currency_code = "USD" | ||
cent_amount = 1000 | ||
} | ||
} | ||
} | ||
`, 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