Remove DisablePublicNetworking option from the Create path (#528)
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
c0a54873af
commit
db10ddb1ee
|
@ -230,7 +230,6 @@ type DropletCreateRequest struct {
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
VPCUUID string `json:"vpc_uuid,omitempty"`
|
VPCUUID string `json:"vpc_uuid,omitempty"`
|
||||||
WithDropletAgent *bool `json:"with_droplet_agent,omitempty"`
|
WithDropletAgent *bool `json:"with_droplet_agent,omitempty"`
|
||||||
DisablePublicNetworking bool `json:"disable_public_networking,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DropletMultiCreateRequest is a request to create multiple Droplets.
|
// DropletMultiCreateRequest is a request to create multiple Droplets.
|
||||||
|
@ -248,7 +247,6 @@ type DropletMultiCreateRequest struct {
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
VPCUUID string `json:"vpc_uuid,omitempty"`
|
VPCUUID string `json:"vpc_uuid,omitempty"`
|
||||||
WithDropletAgent *bool `json:"with_droplet_agent,omitempty"`
|
WithDropletAgent *bool `json:"with_droplet_agent,omitempty"`
|
||||||
DisablePublicNetworking bool `json:"disable_public_networking,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DropletCreateRequest) String() string {
|
func (d DropletCreateRequest) String() string {
|
||||||
|
|
|
@ -394,7 +394,6 @@ func TestDroplets_CreateWithDisabledPublicNetworking(t *testing.T) {
|
||||||
},
|
},
|
||||||
Tags: []string{"one", "two"},
|
Tags: []string{"one", "two"},
|
||||||
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
|
VPCUUID: "880b7f98-f062-404d-b33c-458d545696f6",
|
||||||
DisablePublicNetworking: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mux.HandleFunc("/v2/droplets", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/v2/droplets", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -414,7 +413,6 @@ func TestDroplets_CreateWithDisabledPublicNetworking(t *testing.T) {
|
||||||
},
|
},
|
||||||
"tags": []interface{}{"one", "two"},
|
"tags": []interface{}{"one", "two"},
|
||||||
"vpc_uuid": "880b7f98-f062-404d-b33c-458d545696f6",
|
"vpc_uuid": "880b7f98-f062-404d-b33c-458d545696f6",
|
||||||
"disable_public_networking": true,
|
|
||||||
}
|
}
|
||||||
jsonBlob := `
|
jsonBlob := `
|
||||||
{
|
{
|
||||||
|
@ -457,38 +455,6 @@ func TestDroplets_CreateWithDisabledPublicNetworking(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDroplet_PrivateNetworkingJsonMarshal(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
in *DropletCreateRequest
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
in: &DropletCreateRequest{Name: "foo"},
|
|
||||||
want: `{"name":"foo","region":"","size":"","image":0,"ssh_keys":null,"backups":false,"ipv6":false,"private_networking":false,"monitoring":false,"tags":null}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
in: &DropletCreateRequest{Name: "foo", DisablePublicNetworking: false},
|
|
||||||
want: `{"name":"foo","region":"","size":"","image":0,"ssh_keys":null,"backups":false,"ipv6":false,"private_networking":false,"monitoring":false,"tags":null}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
in: &DropletCreateRequest{Name: "foo", DisablePublicNetworking: true},
|
|
||||||
want: `{"name":"foo","region":"","size":"","image":0,"ssh_keys":null,"backups":false,"ipv6":false,"private_networking":false,"monitoring":false,"tags":null,"disable_public_networking":true}`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
got, err := json.Marshal(tt.in)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(tt.want, string(got)) {
|
|
||||||
t.Errorf("\nexpected: %v\n, got: %v", tt.want, string(got))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDroplets_CreateMultiple(t *testing.T) {
|
func TestDroplets_CreateMultiple(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
28
godo_test.go
28
godo_test.go
|
@ -276,34 +276,6 @@ func TestNewRequest_withDropletAgent(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewRequest_DisablePublicNetworking(t *testing.T) {
|
|
||||||
c := NewClient(nil)
|
|
||||||
|
|
||||||
inURL, outURL := "/foo", defaultBaseURL+"foo"
|
|
||||||
inBody, outBody := &DropletCreateRequest{Name: "l", DisablePublicNetworking: true},
|
|
||||||
`{"name":"l","region":"","size":"","image":0,`+
|
|
||||||
`"ssh_keys":null,"backups":false,"ipv6":false,`+
|
|
||||||
`"private_networking":false,"monitoring":false,"tags":null,"disable_public_networking":true}`+"\n"
|
|
||||||
req, _ := c.NewRequest(ctx, http.MethodPost, inURL, inBody)
|
|
||||||
|
|
||||||
// test relative URL was expanded
|
|
||||||
if req.URL.String() != outURL {
|
|
||||||
t.Errorf("NewRequest(%v) URL = %v, expected %v", inURL, req.URL, outURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
// test body was JSON encoded
|
|
||||||
body, _ := ioutil.ReadAll(req.Body)
|
|
||||||
if string(body) != outBody {
|
|
||||||
t.Errorf("NewRequest(%v)Body = %v, expected %v", inBody, string(body), outBody)
|
|
||||||
}
|
|
||||||
|
|
||||||
// test default user-agent is attached to the request
|
|
||||||
userAgent := req.Header.Get("User-Agent")
|
|
||||||
if c.UserAgent != userAgent {
|
|
||||||
t.Errorf("NewRequest() User-Agent = %v, expected %v", userAgent, c.UserAgent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewRequest_badURL(t *testing.T) {
|
func TestNewRequest_badURL(t *testing.T) {
|
||||||
c := NewClient(nil)
|
c := NewClient(nil)
|
||||||
_, err := c.NewRequest(ctx, http.MethodGet, ":", nil)
|
_, err := c.NewRequest(ctx, http.MethodGet, ":", nil)
|
||||||
|
|
Loading…
Reference in New Issue