Skip to content

Commit

Permalink
fix: Change type on aux so we can nil it.
Browse files Browse the repository at this point in the history
  • Loading branch information
nzdjb committed Jul 7, 2023
1 parent c720441 commit 90370f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
22 changes: 18 additions & 4 deletions client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 3 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestCreateDnsRecord(t *testing.T) {
record := ResourceRecord{
Name: "testrecord",
Type: "A",
Aux: nil,
Data: "127.0.0.1",
Ttl: 300,
}
Expand All @@ -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,
}
Expand Down

0 comments on commit 90370f9

Please sign in to comment.