@@ -3,7 +3,6 @@ package goshopify
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "strings"
7
6
"testing"
8
7
9
8
"github.com/jarcoal/httpmock"
@@ -41,11 +40,25 @@ func inventoryItemTests(t *testing.T, item *InventoryItem) {
41
40
t .Errorf ("InventoryItem.CountryCodeOfOrigin returned %+v, expected %+v" , item .CountryCodeOfOrigin , expectedOrigin )
42
41
}
43
42
44
- // strings.Join is used to compare slices since package's go.mod is set to 1.13
45
- // which predates the experimental slices package that has a Compare() func.
46
- expectedCountryHSCodes := strings .Join ([]string {"8471.70.40.35" , "8471.70.50.35" }, "," )
47
- if strings .Join (item .CountryHarmonizedSystemCodes , "," ) != expectedCountryHSCodes {
48
- t .Errorf ("InventoryItem.CountryHarmonizedSystemCodes returned %+v, expected %+v" , item .CountryHarmonizedSystemCodes , expectedCountryHSCodes )
43
+ expectedCodes := []CountryHarmonizedSystemCode {
44
+ {HarmonizedSystemCode : "8471.70.40.35" , CountryCode : "US" },
45
+ {HarmonizedSystemCode : "8471.70.50.35" , CountryCode : "CA" },
46
+ }
47
+
48
+ if len (item .CountryHarmonizedSystemCodes ) != len (expectedCodes ) {
49
+ t .Errorf ("InventoryItem.CountryHarmonizedSystemCodes length is %d, expected %d" ,
50
+ len (item .CountryHarmonizedSystemCodes ), len (expectedCodes ))
51
+ }
52
+
53
+ for i , code := range item .CountryHarmonizedSystemCodes {
54
+ if code .HarmonizedSystemCode != expectedCodes [i ].HarmonizedSystemCode {
55
+ t .Errorf ("InventoryItem.CountryHarmonizedSystemCodes[%d].HarmonizedSystemCode is %s, expected %s" ,
56
+ i , code .HarmonizedSystemCode , expectedCodes [i ].HarmonizedSystemCode )
57
+ }
58
+ if code .CountryCode != expectedCodes [i ].CountryCode {
59
+ t .Errorf ("InventoryItem.CountryHarmonizedSystemCodes[%d].CountryCode is %s, expected %s" ,
60
+ i , code .CountryCode , expectedCodes [i ].CountryCode )
61
+ }
49
62
}
50
63
51
64
expectedHSCode := "8471.70.40.35"
0 commit comments