From 90370f9f4630cdeb92a3d92b3e76b7fa9a4da9e2 Mon Sep 17 00:00:00 2001 From: nzdjb Date: Fri, 7 Jul 2023 09:27:54 +0000 Subject: [PATCH] fix: Change type on aux so we can nil it. --- client.go | 2 +- client_integration_test.go | 22 ++++++++++++++++++---- client_test.go | 4 +++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 9acb7d7..5ca118e 100644 --- a/client.go +++ b/client.go @@ -22,7 +22,7 @@ type MetanameClient struct { type ResourceRecord struct { Name string `json:"name"` Type string `json:"type"` - Aux int `json:"aux,omitempty"` + Aux *int `json:"aux"` Ttl int `json:"ttl"` Data string `json:"data"` } diff --git a/client_integration_test.go b/client_integration_test.go index 04b995f..cd63d27 100644 --- a/client_integration_test.go +++ b/client_integration_test.go @@ -16,19 +16,33 @@ var testAccountAPIKey string = os.Getenv("METANAME_ACCOUNT_API_KEY") func TestIntegrationConfigureZone(t *testing.T) { c := NewMetanameClient(testAccountReference, testAccountAPIKey) c.Host = "https://test.metaname.net/api/1.1" - err := c.ConfigureZone(context.TODO(), "testzone.nz", []ResourceRecord{}, nil) + aux := int(30) + err := c.ConfigureZone(context.TODO(), "testzone.nz", []ResourceRecord{{ + Name: "george", + Type: "CNAME", + Aux: nil, + Ttl: 600, + Data: "example.org", + }, + { + Name: "mail", + Type: "MX", + Aux: &aux, + Ttl: 600, + Data: "example.org", + }, + }, nil) if err != nil { panic(err) } - assert.Equal(t, "testzone.nz", "testzone.nz") } func TestIntegrationDnsZone(t *testing.T) { c := NewMetanameClient(testAccountReference, testAccountAPIKey) c.Host = "https://test.metaname.net/api/1.1" - _, err := c.DnsZone(context.TODO(), "testzone.nz") + result, err := c.DnsZone(context.TODO(), "testzone.nz") if err != nil { panic(err) } - assert.Equal(t, "testzone.nz", "testzone.nz") + assert.Equal(t, []ResourceRecord(nil), result) } diff --git a/client_test.go b/client_test.go index e50da46..a09b582 100644 --- a/client_test.go +++ b/client_test.go @@ -72,6 +72,7 @@ func TestCreateDnsRecord(t *testing.T) { record := ResourceRecord{ Name: "testrecord", Type: "A", + Aux: nil, Data: "127.0.0.1", Ttl: 300, } @@ -92,10 +93,11 @@ func TestCreateMXDnsRecord(t *testing.T) { AccountReference: "def", APIKey: "ghi", } + x := int(30) record := ResourceRecord{ Name: "testrecord", Type: "MX", - Aux: 30, + Aux: &x, Data: "127.0.0.1", Ttl: 300, }