Remove testing Implements
Make adherenence to interface a compile type rather than a test time check.
This commit is contained in:
parent
ca5927e395
commit
14a4b3f281
|
@ -25,6 +25,8 @@ type ActionsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ ActionsService = &ActionsServiceOp{}
|
||||||
|
|
||||||
type actionsRoot struct {
|
type actionsRoot struct {
|
||||||
Actions []Action `json:"actions"`
|
Actions []Action `json:"actions"`
|
||||||
Links *Links `json:"links"`
|
Links *Links `json:"links"`
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAction_ActionsServiceOpImplementsActionsService(t *testing.T) {
|
|
||||||
if !Implements((*ActionsService)(nil), new(ActionsServiceOp)) {
|
|
||||||
t.Error("ActionsServiceOp does not implement ActionsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAction_List(t *testing.T) {
|
func TestAction_List(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
@ -101,11 +95,11 @@ func TestAction_Get(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
region := &Region{
|
region := &Region{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Slug: "slug",
|
Slug: "slug",
|
||||||
Available: true,
|
Available: true,
|
||||||
Sizes: []string{"512mb"},
|
Sizes: []string{"512mb"},
|
||||||
Features: []string{"virtio"},
|
Features: []string{"virtio"},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(action.Region, region) {
|
if !reflect.DeepEqual(action.Region, region) {
|
||||||
t.Fatalf("unexpected response, invalid region")
|
t.Fatalf("unexpected response, invalid region")
|
||||||
|
|
|
@ -26,6 +26,8 @@ type DomainsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ DomainsService = &DomainsServiceOp{}
|
||||||
|
|
||||||
// Domain represents a Digital Ocean domain
|
// Domain represents a Digital Ocean domain
|
||||||
type Domain struct {
|
type Domain struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAction_DomainsServiceOpImplementsDomainsService(t *testing.T) {
|
|
||||||
if !Implements((*DomainsService)(nil), new(DomainsServiceOp)) {
|
|
||||||
t.Error("DomainsServiceOp does not implement DomainsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDomains_ListDomains(t *testing.T) {
|
func TestDomains_ListDomains(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
|
@ -32,6 +32,8 @@ type DropletActionsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ DropletActionsService = &DropletActionsServiceOp{}
|
||||||
|
|
||||||
// Shutdown a Droplet
|
// Shutdown a Droplet
|
||||||
func (s *DropletActionsServiceOp) Shutdown(id int) (*Action, *Response, error) {
|
func (s *DropletActionsServiceOp) Shutdown(id int) (*Action, *Response, error) {
|
||||||
request := &ActionRequest{"type": "shutdown"}
|
request := &ActionRequest{"type": "shutdown"}
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDropletActions_DropletActionsServiceOpImplementsDropletActionsService(t *testing.T) {
|
|
||||||
if !Implements((*DropletActionsService)(nil), new(DropletActionsServiceOp)) {
|
|
||||||
t.Error("DropletActionsServiceOp does not implement DropletActionsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDropletActions_Shutdown(t *testing.T) {
|
func TestDropletActions_Shutdown(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
|
@ -24,6 +24,8 @@ type DropletsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ DropletsService = &DropletsServiceOp{}
|
||||||
|
|
||||||
// Droplet represents a DigitalOcean Droplet
|
// Droplet represents a DigitalOcean Droplet
|
||||||
type Droplet struct {
|
type Droplet struct {
|
||||||
ID int `json:"id,float64,omitempty"`
|
ID int `json:"id,float64,omitempty"`
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAction_DropletsServiceOpImplementsActionService(t *testing.T) {
|
|
||||||
if !Implements((*DropletsService)(nil), new(DropletsServiceOp)) {
|
|
||||||
t.Error("DropletsServiceOp does not implement DropletsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDroplets_ListDroplets(t *testing.T) {
|
func TestDroplets_ListDroplets(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
|
@ -303,15 +303,6 @@ func TestDo_rateLimit_errorResponse(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
|
||||||
interfaceType := reflect.TypeOf(interfaceObject).Elem()
|
|
||||||
if !reflect.TypeOf(object).Implements(interfaceType) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkCurrentPage(t *testing.T, resp *Response, expectedPage int) {
|
func checkCurrentPage(t *testing.T, resp *Response, expectedPage int) {
|
||||||
links := resp.Links
|
links := resp.Links
|
||||||
p, err := links.CurrentPage()
|
p, err := links.CurrentPage()
|
||||||
|
|
|
@ -16,6 +16,8 @@ type ImageActionsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ ImageActionsService = &ImageActionsServiceOp{}
|
||||||
|
|
||||||
// Transfer an image
|
// Transfer an image
|
||||||
func (i *ImageActionsServiceOp) Transfer(imageID int, transferRequest *ActionRequest) (*Action, *Response, error) {
|
func (i *ImageActionsServiceOp) Transfer(imageID int, transferRequest *ActionRequest) (*Action, *Response, error) {
|
||||||
path := fmt.Sprintf("v2/images/%d/actions", imageID)
|
path := fmt.Sprintf("v2/images/%d/actions", imageID)
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestImageActions_ImageActionsServiceOpImplementsImageActionsService(t *testing.T) {
|
|
||||||
if !Implements((*ImageActionsService)(nil), new(ImageActionsServiceOp)) {
|
|
||||||
t.Error("ImageActionsServiceOp does not implement ImageActionsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestImageActions_Transfer(t *testing.T) {
|
func TestImageActions_Transfer(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
|
@ -13,6 +13,8 @@ type ImagesServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ ImagesService = &ImagesServiceOp{}
|
||||||
|
|
||||||
// Image represents a DigitalOcean Image
|
// Image represents a DigitalOcean Image
|
||||||
type Image struct {
|
type Image struct {
|
||||||
ID int `json:"id,float64,omitempty"`
|
ID int `json:"id,float64,omitempty"`
|
||||||
|
|
|
@ -7,12 +7,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestImages_ImagesServiceOpImplementsImagesService(t *testing.T) {
|
|
||||||
if !Implements((*ImagesService)(nil), new(ImagesServiceOp)) {
|
|
||||||
t.Error("ImagesServiceOp does not implement ImagesService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestImages_List(t *testing.T) {
|
func TestImages_List(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
2
keys.go
2
keys.go
|
@ -22,6 +22,8 @@ type KeysServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ KeysService = &KeysServiceOp{}
|
||||||
|
|
||||||
// Key represents a DigitalOcean Key.
|
// Key represents a DigitalOcean Key.
|
||||||
type Key struct {
|
type Key struct {
|
||||||
ID int `json:"id,float64,omitempty"`
|
ID int `json:"id,float64,omitempty"`
|
||||||
|
|
|
@ -8,12 +8,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestKeys_KeysServiceOpImplementsKeysService(t *testing.T) {
|
|
||||||
if !Implements((*KeysService)(nil), new(KeysServiceOp)) {
|
|
||||||
t.Error("KeysServiceOp does not implement KeysService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestKeys_List(t *testing.T) {
|
func TestKeys_List(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
|
@ -13,6 +13,8 @@ type RegionsServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ RegionsService = &RegionsServiceOp{}
|
||||||
|
|
||||||
// Region represents a DigitalOcean Region
|
// Region represents a DigitalOcean Region
|
||||||
type Region struct {
|
type Region struct {
|
||||||
Slug string `json:"slug,omitempty"`
|
Slug string `json:"slug,omitempty"`
|
||||||
|
|
|
@ -7,12 +7,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRegions_RegionsServiceOpImplementsRegionsService(t *testing.T) {
|
|
||||||
if !Implements((*RegionsService)(nil), new(RegionsServiceOp)) {
|
|
||||||
t.Error("RegionsServiceOp does not implement RegionsService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRegions_List(t *testing.T) {
|
func TestRegions_List(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
2
sizes.go
2
sizes.go
|
@ -13,6 +13,8 @@ type SizesServiceOp struct {
|
||||||
client *Client
|
client *Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ SizesService = &SizesServiceOp{}
|
||||||
|
|
||||||
// Size represents a DigitalOcean Size
|
// Size represents a DigitalOcean Size
|
||||||
type Size struct {
|
type Size struct {
|
||||||
Slug string `json:"slug,omitempty"`
|
Slug string `json:"slug,omitempty"`
|
||||||
|
|
|
@ -7,12 +7,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSizes_SizesServiceOpImplementsSizesService(t *testing.T) {
|
|
||||||
if !Implements((*SizesService)(nil), new(SizesServiceOp)) {
|
|
||||||
t.Error("SizesServiceOp does not implement SizesService")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSizes_List(t *testing.T) {
|
func TestSizes_List(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
|
|
Loading…
Reference in New Issue