Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewName should be optional #252

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion fastly/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type UpdateDomainInput struct {
Name string

// NewName is the updated name of the domain
NewName string `form:"name"`
NewName *string `form:"name,omitempty"`

// Comment is a personal, freeform descriptive note.
Comment *string `form:"comment,omitempty"`
Expand All @@ -172,6 +172,10 @@ func (c *Client) UpdateDomain(i *UpdateDomainInput) (*Domain, error) {
return nil, ErrMissingName
}

if i.NewName == nil && i.Comment == nil {
return nil, ErrMissingOptionalNameComment
}

path := fmt.Sprintf("/service/%s/version/%d/domain/%s", i.ServiceID, i.ServiceVersion, url.PathEscape(i.Name))
resp, err := c.PutForm(path, i, nil)
if err != nil {
Expand Down
11 changes: 10 additions & 1 deletion fastly/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestClient_Domains(t *testing.T) {
ServiceID: testServiceID,
ServiceVersion: tv.Number,
Name: "integ-test.go-fastly.com",
NewName: "new-integ-test.go-fastly.com",
NewName: String("new-integ-test.go-fastly.com"),
})
})
if err != nil {
Expand Down Expand Up @@ -203,6 +203,15 @@ func TestClient_UpdateDomain_validation(t *testing.T) {
if err != ErrMissingName {
t.Errorf("bad error: %s", err)
}

_, err = testClient.UpdateDomain(&UpdateDomainInput{
ServiceID: "foo",
ServiceVersion: 1,
Name: "bar",
})
if err != ErrMissingOptionalNameComment {
t.Errorf("bad error: %s", err)
}
}

func TestClient_DeleteDomain_validation(t *testing.T) {
Expand Down