Skip to content

Commit d0f7a0a

Browse files
committed
Fix another testcase for shipping zone locations
The resource create logic still assumed the shipping zone locations was a list instead of a set
1 parent 6c9e22c commit d0f7a0a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

commercetools/resource_shipping_zone.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func resourceShippingZoneCreate(ctx context.Context, d *schema.ResourceData, m i
6565
log.Print("[DEBUG] Creating shippingzones in commercetools")
6666
client := getClient(m)
6767

68-
input := d.Get("location").([]interface{})
68+
input := d.Get("location").(*schema.Set)
6969
locations := expandShippingZoneLocations(input)
7070

7171
draft := platform.ZoneDraft{
@@ -160,8 +160,8 @@ func resourceShippingZoneUpdate(ctx context.Context, d *schema.ResourceData, m i
160160
if d.HasChange("location") {
161161
old, new := d.GetChange("location")
162162

163-
oldLocations := expandShippingZoneLocations(old)
164-
newLocations := expandShippingZoneLocations(new)
163+
oldLocations := expandShippingZoneLocations(old.(*schema.Set))
164+
newLocations := expandShippingZoneLocations(new.(*schema.Set))
165165

166166
for i, location := range oldLocations {
167167
if !_locationInSlice(location, newLocations) {
@@ -202,9 +202,8 @@ func resourceShippingZoneDelete(ctx context.Context, d *schema.ResourceData, m i
202202
return diag.FromErr(err)
203203
}
204204

205-
func expandShippingZoneLocations(input interface{}) []platform.Location {
206-
inputSet := input.(*schema.Set)
207-
inputSlice := inputSet.List()
205+
func expandShippingZoneLocations(input *schema.Set) []platform.Location {
206+
inputSlice := input.List()
208207
result := make([]platform.Location, len(inputSlice))
209208

210209
for i := range inputSlice {

0 commit comments

Comments
 (0)