Skip to content

Commit

Permalink
Remove testing Implements
Browse files Browse the repository at this point in the history
Make adherenence to interface a compile type rather than a test time check.
  • Loading branch information
bryanl committed Mar 21, 2015
1 parent ca5927e commit 14a4b3f
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 67 deletions.
2 changes: 2 additions & 0 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type ActionsServiceOp struct {
client *Client
}

var _ ActionsService = &ActionsServiceOp{}

type actionsRoot struct {
Actions []Action `json:"actions"`
Links *Links `json:"links"`
Expand Down
14 changes: 4 additions & 10 deletions action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions droplet_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
6 changes: 0 additions & 6 deletions droplet_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions droplets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions droplets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 0 additions & 9 deletions godo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions image_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions image_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions regions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions regions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions sizes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 14a4b3f

Please sign in to comment.