Merge pull request #200 from digitalocean/issues/198

Fix return of Domains.EditRecord function (Fixes: #198).
This commit is contained in:
Eddie Zaneski 2019-02-02 09:00:06 -07:00 committed by GitHub
commit 2b8286756e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -294,18 +294,18 @@ func (s *DomainsServiceOp) EditRecord(ctx context.Context,
path := fmt.Sprintf("%s/%s/records/%d", domainsBasePath, domain, id)
req, err := s.client.NewRequest(ctx, "PUT", path, editRequest)
req, err := s.client.NewRequest(ctx, http.MethodPut, path, editRequest)
if err != nil {
return nil, nil, err
}
d := new(DomainRecord)
resp, err := s.client.Do(ctx, req, d)
root := new(domainRecordRoot)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, resp, err
}
return d, resp, err
return root.DomainRecord, resp, err
}
// CreateRecord creates a record using a DomainRecordEditRequest

View File

@ -291,12 +291,12 @@ func TestDomains_EditRecordForDomainName(t *testing.T) {
t.Fatalf("decode json: %v", err)
}
testMethod(t, r, "PUT")
testMethod(t, r, http.MethodPut)
if !reflect.DeepEqual(v, editRequest) {
t.Errorf("Request body = %+v, expected %+v", v, editRequest)
}
fmt.Fprintf(w, `{"id":1}`)
fmt.Fprintf(w, `{"domain_record": {"id":1, "type": "CNAME", "name": "example"}}`)
})
record, _, err := client.Domains.EditRecord(ctx, "example.com", 1, editRequest)
@ -304,7 +304,7 @@ func TestDomains_EditRecordForDomainName(t *testing.T) {
t.Errorf("Domains.EditRecord returned error: %v", err)
}
expected := &DomainRecord{ID: 1}
expected := &DomainRecord{ID: 1, Type: "CNAME", Name: "example"}
if !reflect.DeepEqual(record, expected) {
t.Errorf("Domains.EditRecord returned %+v, expected %+v", record, expected)
}