Skip to content

Commit

Permalink
Merge pull request #67 from ddymko/dns-priority
Browse files Browse the repository at this point in the history
DNS Record Update Priority
  • Loading branch information
ddymko authored Jun 2, 2020
2 parents e8d9613 + 2b3525b commit d79aa63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dns_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type DNSRecord struct {
Type string `json:"type"`
Name string `json:"name"`
Data string `json:"data"`
Priority int `json:"priority"`
Priority *int `json:"priority"`
TTL int `json:"ttl"`
}

Expand Down Expand Up @@ -130,8 +130,8 @@ func (d *DNSRecordsServiceHandler) Update(ctx context.Context, domain string, dn
if dnsRecord.TTL != 0 {
values.Add("ttl", strconv.Itoa(dnsRecord.TTL))
}
if dnsRecord.Priority != 0 {
values.Add("priority", strconv.Itoa(dnsRecord.Priority))
if dnsRecord.Priority != nil {
values.Add("priority", strconv.Itoa(*dnsRecord.Priority))
}

req, err := d.client.NewRequest(ctx, http.MethodPost, uri, values)
Expand Down
10 changes: 5 additions & 5 deletions dns_records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ func TestDNSRecordsServiceHandler_List(t *testing.T) {
if err != nil {
t.Errorf("DNSRecord.List returned %+v, expected %+v", err, nil)
}

p := 0
expected := []DNSRecord{
{Type: "A", Name: "", Data: "127.0.0.1", Priority: 0, RecordID: 1265276, TTL: 300},
{Type: "A", Name: "", Data: "127.0.0.1", Priority: 0, RecordID: 1265276, TTL: 300},
{Type: "A", Name: "", Data: "127.0.0.1", Priority: &p, RecordID: 1265276, TTL: 300},
{Type: "A", Name: "", Data: "127.0.0.1", Priority: &p, RecordID: 1265276, TTL: 300},
}

if !reflect.DeepEqual(records, expected) {
Expand All @@ -70,13 +70,13 @@ func TestDNSRecordsServiceHandler_Update(t *testing.T) {

fmt.Fprint(writer)
})

p := 10
params := &DNSRecord{
RecordID: 14283638,
Name: "api",
Data: "turnip.data",
TTL: 120,
Priority: 10,
Priority: &p,
}

err := client.DNSRecord.Update(ctx, "turnip.services", params)
Expand Down

0 comments on commit d79aa63

Please sign in to comment.