Skip to content

Commit 705b980

Browse files
author
Stein Fletcher
committed
Remove dependency on testify
1 parent 80e7a5a commit 705b980

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+310
-5128
lines changed

apitest.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ func (a *APITest) Intercept(interceptor Intercept) *APITest {
240240
}
241241

242242
// Verifier allows consumers to override the verification implementation.
243-
// By default testify is used to perform assertions
244243
func (a *APITest) Verifier(v Verifier) *APITest {
245244
a.verifier = v
246245
return a
@@ -801,7 +800,7 @@ func (r *Response) runTest() *http.Response {
801800
}()
802801

803802
if a.verifier == nil {
804-
a.verifier = newTestifyVerifier()
803+
a.verifier = DefaultVerifier{}
805804
}
806805

807806
a.assertMocks()

apitest_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313

1414
"github.com/steinfletcher/apitest"
1515
"github.com/steinfletcher/apitest/mocks"
16-
17-
"github.com/stretchr/testify/assert"
1816
)
1917

2018
func TestApiTest_ResponseBody(t *testing.T) {
@@ -803,13 +801,13 @@ func TestApiTest_Report(t *testing.T) {
803801
r := reporter.capturedRecorder
804802
assert.Equal(t, "POST /hello", r.Title)
805803
assert.Equal(t, "some test", r.SubTitle)
806-
assert.Len(t, r.Events, 4)
804+
assert.Equal(t, 4, len(r.Events))
807805
assert.Equal(t, 200, r.Meta["status_code"])
808806
assert.Equal(t, "/hello", r.Meta["path"])
809807
assert.Equal(t, "POST", r.Meta["method"])
810808
assert.Equal(t, "some test", r.Meta["name"])
811809
assert.Equal(t, "abc.com", r.Meta["host"])
812-
assert.NotEmpty(t, r.Meta["duration"])
810+
assert.Equal(t, true, r.Meta["duration"] != nil)
813811
}
814812

815813
func TestApiTest_Recorder(t *testing.T) {
@@ -857,7 +855,7 @@ func TestApiTest_Recorder(t *testing.T) {
857855
End()
858856

859857
r := reporter.capturedRecorder
860-
assert.Len(t, r.Events, 6)
858+
assert.Equal(t, 6, len(r.Events))
861859
assert.Equal(t, messageRequest, r.Events[0])
862860
assert.Equal(t, messageResponse, r.Events[1])
863861
}
@@ -881,7 +879,7 @@ func TestApiTest_Observe(t *testing.T) {
881879
Status(http.StatusOK).
882880
End()
883881

884-
assert.True(t, observeCalled)
882+
assert.Equal(t, true, observeCalled)
885883
}
886884

887885
func TestApiTest_Observe_DumpsTheHttpRequestAndResponse(t *testing.T) {
@@ -926,7 +924,7 @@ func TestApiTest_ObserveWithReport(t *testing.T) {
926924
Status(http.StatusOK).
927925
End()
928926

929-
assert.True(t, observeCalled)
927+
assert.Equal(t, true, observeCalled)
930928
}
931929

932930
func TestApiTest_Intercept(t *testing.T) {
@@ -960,8 +958,8 @@ func TestApiTest_Intercept(t *testing.T) {
960958
func TestApiTest_ExposesRequestAndResponse(t *testing.T) {
961959
apiTest := apitest.New()
962960

963-
assert.NotNil(t, apiTest.Request())
964-
assert.NotNil(t, apiTest.Response())
961+
assert.Equal(t, true, apiTest.Request() != nil)
962+
assert.Equal(t, true, apiTest.Response() != nil)
965963
}
966964

967965
func TestApiTest_RequestContextIsPreserved(t *testing.T) {
@@ -1142,7 +1140,7 @@ func TestApiTest_ErrorIfMockInvocationsDoNotMatchTimes(t *testing.T) {
11421140
End()
11431141

11441142
unmatchedMocks := res.UnmatchedMocks()
1145-
assert.NotEmpty(t, unmatchedMocks)
1143+
assert.Equal(t, true, len(unmatchedMocks) > 0)
11461144
assert.Equal(t, "http://localhost:8080", unmatchedMocks[0].URL.String())
11471145
}
11481146

@@ -1165,7 +1163,7 @@ func TestApiTest_MatchesTimes(t *testing.T) {
11651163
Status(http.StatusOK).
11661164
End()
11671165

1168-
assert.Empty(t, res.UnmatchedMocks())
1166+
assert.Equal(t, 0, len(res.UnmatchedMocks()))
11691167
}
11701168

11711169
type RecorderCaptor struct {
@@ -1187,3 +1185,5 @@ func getUserData() []byte {
11871185
}
11881186
return data
11891187
}
1188+
1189+
var assert = apitest.DefaultVerifier{}

0 commit comments

Comments
 (0)