Skip to content

Commit

Permalink
Add test for ZoneUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed Dec 31, 2016
1 parent cf4e64c commit 7044ad8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions zoneMethods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,34 @@ func TestZoneCreateValidResponse(t *testing.T) {
t.Errorf("error: %v", err)
}
}

func TestZoneUpdateWithError(t *testing.T) {
originalMethodPost := methodPost
methodPost = "(" // invalid method
defer func() { methodPost = originalMethodPost }()

_, err := ZoneUpdate("", "", "")

expected := "error in MakePost"
result := err.Error()
if strings.Index(result, expected) != 0 {
t.Errorf("error does not found: %s", result)
}
}

func TestZoneUpdateValidResponse(t *testing.T) {
mock := dozensMock{
Method: methodPost,
URL: endpoint.ZoneUpdate("").String(),
Status: http.StatusOK,
Response: validZoneResponse,
}

_, err := mock.Do(func() (interface{}, error) {
return ZoneUpdate("", "", "")
})

if err != nil {
t.Errorf("error: %v", err)
}
}

0 comments on commit 7044ad8

Please sign in to comment.