Remove testing Implements

Make adherenence to interface a compile type rather than a test time check.
This commit is contained in:
bryanl 2015-03-21 15:42:48 -04:00
parent ca5927e395
commit 14a4b3f281
19 changed files with 22 additions and 67 deletions

View File

@ -25,6 +25,8 @@ type ActionsServiceOp struct {
client *Client
}
var _ ActionsService = &ActionsServiceOp{}
type actionsRoot struct {
Actions []Action `json:"actions"`
Links *Links `json:"links"`

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()
@ -101,11 +95,11 @@ func TestAction_Get(t *testing.T) {
}
region := &Region{
Name: "name",
Slug: "slug",
Name: "name",
Slug: "slug",
Available: true,
Sizes: []string{"512mb"},
Features: []string{"virtio"},
Sizes: []string{"512mb"},
Features: []string{"virtio"},
}
if !reflect.DeepEqual(action.Region, region) {
t.Fatalf("unexpected response, invalid region")

View File

@ -26,6 +26,8 @@ type DomainsServiceOp struct {
client *Client
}
var _ DomainsService = &DomainsServiceOp{}
// Domain represents a Digital Ocean domain
type Domain struct {
Name string `json:"name"`

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -32,6 +32,8 @@ type DropletActionsServiceOp struct {
client *Client
}
var _ DropletActionsService = &DropletActionsServiceOp{}
// Shutdown a Droplet
func (s *DropletActionsServiceOp) Shutdown(id int) (*Action, *Response, error) {
request := &ActionRequest{"type": "shutdown"}

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -24,6 +24,8 @@ type DropletsServiceOp struct {
client *Client
}
var _ DropletsService = &DropletsServiceOp{}
// Droplet represents a DigitalOcean Droplet
type Droplet struct {
ID int `json:"id,float64,omitempty"`

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -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) {
links := resp.Links
p, err := links.CurrentPage()

View File

@ -16,6 +16,8 @@ type ImageActionsServiceOp struct {
client *Client
}
var _ ImageActionsService = &ImageActionsServiceOp{}
// Transfer an image
func (i *ImageActionsServiceOp) Transfer(imageID int, transferRequest *ActionRequest) (*Action, *Response, error) {
path := fmt.Sprintf("v2/images/%d/actions", imageID)

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -13,6 +13,8 @@ type ImagesServiceOp struct {
client *Client
}
var _ ImagesService = &ImagesServiceOp{}
// Image represents a DigitalOcean Image
type Image struct {
ID int `json:"id,float64,omitempty"`

View File

@ -7,12 +7,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -22,6 +22,8 @@ type KeysServiceOp struct {
client *Client
}
var _ KeysService = &KeysServiceOp{}
// Key represents a DigitalOcean Key.
type Key struct {
ID int `json:"id,float64,omitempty"`

View File

@ -8,12 +8,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -13,6 +13,8 @@ type RegionsServiceOp struct {
client *Client
}
var _ RegionsService = &RegionsServiceOp{}
// Region represents a DigitalOcean Region
type Region struct {
Slug string `json:"slug,omitempty"`

View File

@ -7,12 +7,6 @@ import (
"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) {
setup()
defer teardown()

View File

@ -13,6 +13,8 @@ type SizesServiceOp struct {
client *Client
}
var _ SizesService = &SizesServiceOp{}
// Size represents a DigitalOcean Size
type Size struct {
Slug string `json:"slug,omitempty"`

View File

@ -7,12 +7,6 @@ import (
"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) {
setup()
defer teardown()