From 0ec794a37ba1dfe0cc93892ef33fc2e7daddc759 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 2 Mar 2024 14:22:25 -0800 Subject: [PATCH] nullable/ommitempty fixes for #182 --- carrier.go | 2 +- carrier_test.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/carrier.go b/carrier.go index c9eddb3e..10566c76 100644 --- a/carrier.go +++ b/carrier.go @@ -30,7 +30,7 @@ type CarrierServiceOp struct { // CarrierService represents a Shopify carrier service type CarrierService struct { // Whether this carrier service is active. - Active bool `json:"active,omitempty"` + Active *bool `json:"active"` // The URL endpoint that Shopify needs to retrieve shipping rates. This must be a public URL. CallbackUrl string `json:"callback_url,omitempty"` diff --git a/carrier_test.go b/carrier_test.go index e8659261..f5d0e988 100644 --- a/carrier_test.go +++ b/carrier_test.go @@ -21,11 +21,13 @@ func TestCarrierList(t *testing.T) { t.Errorf("Carrier.List returned error: %v", err) } + trueVar := true + expected := []CarrierService{ { Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -50,10 +52,12 @@ func TestCarrierGet(t *testing.T) { t.Errorf("Carrier.Get returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -77,10 +81,12 @@ func TestCarrierCreate(t *testing.T) { t.Errorf("Carrier.Create returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -104,10 +110,12 @@ func TestCarrierUpdate(t *testing.T) { t.Errorf("Carrier.Update returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1",