Skip to content

Commit fd677ec

Browse files
committed
feat(domain): add procfile_type
1 parent 6be5299 commit fd677ec

4 files changed

Lines changed: 30 additions & 24 deletions

File tree

api/domains.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package api
22

33
// Domain is the structure of the domain object.
44
type Domain struct {
5-
App string `json:"app"`
6-
Created string `json:"created"`
7-
Domain string `json:"domain"`
8-
Owner string `json:"owner"`
9-
Updated string `json:"updated"`
5+
App string `json:"app"`
6+
Created string `json:"created"`
7+
Domain string `json:"domain"`
8+
Owner string `json:"owner"`
9+
ProcfileType string `json:"procfile_type"`
10+
Updated string `json:"updated"`
1011
}
1112

1213
// Domains defines a collection of domain objects.
@@ -18,5 +19,6 @@ func (d Domains) Less(i, j int) bool { return d[i].Domain < d[j].Domain }
1819

1920
// DomainCreateRequest is the structure of POST /v2/app/<app id>/domains/.
2021
type DomainCreateRequest struct {
21-
Domain string `json:"domain"`
22+
Domain string `json:"domain"`
23+
ProcfileType string `json:"procfile_type"`
2224
}

api/domains_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77

88
func TestDomainsSorted(t *testing.T) {
99
domains := Domains{
10-
{"Alpha", "", "gamma.example.com", "", ""},
11-
{"Alpha", "", "alpha1.example.com", "", ""},
12-
{"Alpha", "", "zulu.example.com", "", ""},
13-
{"Alpha", "", "delta.example.com", "", ""},
10+
{"Alpha", "", "gamma.example.com", "web", "", ""},
11+
{"Alpha", "", "alpha1.example.com", "web", "", ""},
12+
{"Alpha", "", "zulu.example.com", "web", "", ""},
13+
{"Alpha", "", "delta.example.com", "web", "", ""},
1414
}
1515

1616
sort.Sort(domains)

domains/domains.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func List(c *drycc.Client, appID string, results int) (api.Domains, int, error)
2727
}
2828

2929
// New adds a domain to an app.
30-
func New(c *drycc.Client, appID string, domain string) (api.Domain, error) {
30+
func New(c *drycc.Client, appID, domain, procfileType string) (api.Domain, error) {
3131
u := fmt.Sprintf("/v2/apps/%s/domains/", appID)
3232

33-
req := api.DomainCreateRequest{Domain: domain}
33+
req := api.DomainCreateRequest{Domain: domain, ProcfileType: procfileType}
3434

3535
body, err := json.Marshal(req)
3636

domains/domains_test.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const domainsFixture string = `
2222
"app": "example-go",
2323
"created": "2014-01-01T00:00:00UTC",
2424
"domain": "example.example.com",
25+
"procfile_type": "web",
2526
"owner": "test",
2627
"updated": "2014-01-01T00:00:00UTC"
2728
}
@@ -33,11 +34,12 @@ const domainFixture string = `
3334
"app": "example-go",
3435
"created": "2014-01-01T00:00:00UTC",
3536
"domain": "example.example.com",
37+
"procfile_type": "web",
3638
"owner": "test",
3739
"updated": "2014-01-01T00:00:00UTC"
3840
}`
3941

40-
const domainCreateExpected string = `{"domain":"example.example.com"}`
42+
const domainCreateExpected string = `{"domain":"example.example.com","procfile_type":"web"}`
4143

4244
type fakeHTTPServer struct{}
4345

@@ -86,11 +88,12 @@ func TestDomainsList(t *testing.T) {
8688

8789
expected := api.Domains{
8890
{
89-
App: "example-go",
90-
Created: "2014-01-01T00:00:00UTC",
91-
Domain: "example.example.com",
92-
Owner: "test",
93-
Updated: "2014-01-01T00:00:00UTC",
91+
App: "example-go",
92+
Created: "2014-01-01T00:00:00UTC",
93+
Domain: "example.example.com",
94+
ProcfileType: "web",
95+
Owner: "test",
96+
Updated: "2014-01-01T00:00:00UTC",
9497
},
9598
}
9699

@@ -118,11 +121,12 @@ func TestDomainsAdd(t *testing.T) {
118121
t.Parallel()
119122

120123
expected := api.Domain{
121-
App: "example-go",
122-
Created: "2014-01-01T00:00:00UTC",
123-
Domain: "example.example.com",
124-
Owner: "test",
125-
Updated: "2014-01-01T00:00:00UTC",
124+
App: "example-go",
125+
Created: "2014-01-01T00:00:00UTC",
126+
Domain: "example.example.com",
127+
ProcfileType: "web",
128+
Owner: "test",
129+
Updated: "2014-01-01T00:00:00UTC",
126130
}
127131

128132
handler := fakeHTTPServer{}
@@ -134,7 +138,7 @@ func TestDomainsAdd(t *testing.T) {
134138
t.Fatal(err)
135139
}
136140

137-
actual, err := New(drycc, "example-go", "example.example.com")
141+
actual, err := New(drycc, "example-go", "example.example.com", "web")
138142

139143
if err != nil {
140144
t.Fatal(err)

0 commit comments

Comments
 (0)