Skip to content

Commit

Permalink
Merge pull request #7 from maxcnunes/6-use-testing-tb
Browse files Browse the repository at this point in the history
switch to using testing.TB vs a concrete testing state type
  • Loading branch information
erutherford authored Mar 22, 2021
2 parents 4368940 + 3751bd3 commit 1e7e58f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions httpfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ import (
type HTTPFake struct {
Server *httptest.Server
RequestHandlers []*Request
t *testing.T
t testing.TB
}

// ServerOption provides a functional signature for providing configuration options to the fake server
type ServerOption func(opts *ServerOptions)

// ServerOptions a configuration object for the fake test server
type ServerOptions struct {
t *testing.T
t testing.TB
}

// WithTesting returns a configuration function that allows you to configure the testing object on the fake server.
// The testing object is utilized for assertions set on the request object and will throw a testing error if an
// endpoint is not called.
func WithTesting(t *testing.T) ServerOption {
func WithTesting(t testing.TB) ServerOption {
return func(opts *ServerOptions) {
opts.t = t
}
Expand Down
2 changes: 1 addition & 1 deletion request.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (r *Request) method(method, path string) *Request {
return r
}

func (r *Request) runAssertions(t *testing.T, testReq *http.Request) {
func (r *Request) runAssertions(t testing.TB, testReq *http.Request) {
for _, assertor := range r.assertions {
assertor.Log(t)
if err := assertor.Assert(testReq); err != nil {
Expand Down

0 comments on commit 1e7e58f

Please sign in to comment.