Skip to content

Commit da227ce

Browse files
author
Francisco Souza
committed
encodingcom: get rid of gocheck
This was long due
1 parent da860fd commit da227ce

8 files changed

+674
-331
lines changed

api_status_test.go

+27-14
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,48 @@ package encodingcom
33
import (
44
"net/http"
55
"net/http/httptest"
6-
7-
"gopkg.in/check.v1"
6+
"reflect"
7+
"testing"
88
)
99

10-
func (s *S) TestAPIStatus(c *check.C) {
10+
func TestAPIStatus(t *testing.T) {
1111
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1212
w.Write([]byte(`{"status":"Encoding Queue Processing Delays","status_code":"queue_slow","incident":"Our encoding queue is processing slower than normal. Check back for updates."}`))
1313
}))
1414
defer server.Close()
1515
resp, err := APIStatus(server.URL)
16-
c.Assert(err, check.IsNil)
17-
c.Assert(*resp, check.DeepEquals, APIStatusResponse{
16+
if err != nil {
17+
t.Fatal(err)
18+
}
19+
expectedResp := APIStatusResponse{
1820
Status: "Encoding Queue Processing Delays",
1921
StatusCode: "queue_slow",
2022
Incident: "Our encoding queue is processing slower than normal. Check back for updates.",
21-
})
23+
}
24+
if !reflect.DeepEqual(*resp, expectedResp) {
25+
t.Errorf("wrong response returned\nwant %#v\ngot %#v", expectedResp, *resp)
26+
}
2227
}
2328

24-
func (s *S) TestAPIStatusFailToConnect(c *check.C) {
29+
func TestAPIStatusFailToConnect(t *testing.T) {
2530
_, err := APIStatus("http://192.0.2.13:8080")
26-
c.Assert(err, check.NotNil)
31+
if err == nil {
32+
t.Fatal("unexpected <nil> error")
33+
}
2734
}
2835

29-
func (s *S) TestAPIStatusInvalidResponse(c *check.C) {
36+
func TestAPIStatusInvalidResponse(t *testing.T) {
3037
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3138
w.Write([]byte(`{not a valid json}`))
3239
}))
3340
defer server.Close()
3441
_, err := APIStatus(server.URL)
35-
c.Assert(err, check.NotNil)
42+
if err == nil {
43+
t.Fatal("unexpected <nil> error")
44+
}
3645
}
3746

38-
func (s *S) TestAPIStatusOK(c *check.C) {
47+
func TestAPIStatusOK(t *testing.T) {
3948
var tests = []struct {
4049
input string
4150
want bool
@@ -47,8 +56,12 @@ func (s *S) TestAPIStatusOK(c *check.C) {
4756
{"pc_queue_slow", false},
4857
}
4958
for _, test := range tests {
50-
status := APIStatusResponse{StatusCode: test.input}
51-
got := status.OK()
52-
c.Check(got, check.Equals, test.want)
59+
t.Run(test.input, func(t *testing.T) {
60+
status := APIStatusResponse{StatusCode: test.input}
61+
got := status.OK()
62+
if got != test.want {
63+
t.Errorf("wrong status returned\nwant %v\ngot %v", test.want, got)
64+
}
65+
})
5366
}
5467
}

0 commit comments

Comments
 (0)