Skip to content

Commit

Permalink
provide log only implementation of T
Browse files Browse the repository at this point in the history
  • Loading branch information
Sapexoid committed Feb 20, 2023
1 parent 1cab4b5 commit fbd31d6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions httpmockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"io"
"log"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -75,8 +76,29 @@ type T interface {
Errorf(format string, args ...interface{})
}

type LoggerT struct {
}

func (l *LoggerT) Helper() {}

func (l *LoggerT) Fatal(args ...interface{}) {
log.Fatal(args...)
}

func (l *LoggerT) Fatalf(format string, args ...interface{}) {
log.Fatalf(format, args...)
}

func (l *LoggerT) Errorf(format string, args ...interface{}) {
log.Printf(format, args...)
}

// NewWithOpts can be used to create a mock server with custom options
func NewWithOpts(t T, opts Opts) MockServer {
if t == nil {
t = &LoggerT{}
}

t.Helper()
err := opts.validate()
if err != nil {
Expand Down

0 comments on commit fbd31d6

Please sign in to comment.