Use a test logger
This commit is contained in:
parent
bbae88ab4b
commit
63cefd403e
@ -70,13 +70,10 @@ type divider interface {
|
||||
Divide2FromMeta(ctx context.Context) (int, error)
|
||||
}
|
||||
|
||||
var testHandler = func() Handler {
|
||||
func testHandler(t *testing.T) Handler {
|
||||
var (
|
||||
logger = mlog.NewLogger(&mlog.LoggerOpts{
|
||||
MaxLevel: mlog.LevelDebug.Int(),
|
||||
})
|
||||
|
||||
d = divider(dividerImpl{})
|
||||
logger = mlog.NewTestLogger(t)
|
||||
d = divider(dividerImpl{})
|
||||
)
|
||||
|
||||
return Chain(
|
||||
@ -85,7 +82,7 @@ var testHandler = func() Handler {
|
||||
)(
|
||||
NewDispatchHandler(&d),
|
||||
)
|
||||
}()
|
||||
}
|
||||
|
||||
func testClient(t *testing.T, client Client) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
@ -194,7 +191,7 @@ func TestReadWriter(t *testing.T) {
|
||||
clientRW = rw{clientReader, clientWriter}
|
||||
handlerRW = rw{handlerReader, handlerWriter}
|
||||
|
||||
server = NewReadWriterServer(testHandler, handlerRW)
|
||||
server = NewReadWriterServer(testHandler(t), handlerRW)
|
||||
client = NewReadWriterClient(clientRW)
|
||||
|
||||
wg = new(sync.WaitGroup)
|
||||
@ -220,7 +217,7 @@ func TestReadWriter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTP(t *testing.T) {
|
||||
server := httptest.NewServer(NewHTTPHandler(testHandler))
|
||||
server := httptest.NewServer(NewHTTPHandler(testHandler(t)))
|
||||
t.Cleanup(server.Close)
|
||||
testClient(t, NewHTTPClient(server.URL))
|
||||
}
|
||||
@ -228,7 +225,7 @@ func TestHTTP(t *testing.T) {
|
||||
func TestUnixHTTP(t *testing.T) {
|
||||
var (
|
||||
unixSocketPath = filepath.Join(t.TempDir(), "test.sock")
|
||||
server = httptest.NewUnstartedServer(NewHTTPHandler(testHandler))
|
||||
server = httptest.NewUnstartedServer(NewHTTPHandler(testHandler(t)))
|
||||
)
|
||||
|
||||
var err error
|
||||
|
@ -102,7 +102,7 @@ func newIntegrationHarness(t *testing.T) *integrationHarness {
|
||||
|
||||
return &integrationHarness{
|
||||
ctx: context.Background(),
|
||||
logger: mlog.NewLogger(nil),
|
||||
logger: mlog.NewTestLogger(t),
|
||||
rootDir: toolkit.Dir{Path: rootDir},
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ go 1.22
|
||||
|
||||
require (
|
||||
code.betamike.com/micropelago/pmux v0.0.0-20240719134913-f5fce902e8c4
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20241023182613-55984cdf5233
|
||||
github.com/adrg/xdg v0.4.0
|
||||
github.com/jxskiss/base62 v1.1.0
|
||||
github.com/minio/minio-go/v7 v7.0.28
|
||||
|
@ -2,6 +2,10 @@ code.betamike.com/micropelago/pmux v0.0.0-20240719134913-f5fce902e8c4 h1:n4pGP12
|
||||
code.betamike.com/micropelago/pmux v0.0.0-20240719134913-f5fce902e8c4/go.mod h1:WlEWacLREVfIQl1IlBjKzuDgL56DFRvyl7YiL5gGP4w=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7 h1:wKQ3bXzG+KQDtRAN/xaRZ4aQtJe1pccleG6V43MvFxw=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20240511135822-4ab1176672d7/go.mod h1:nP+AtQWrc3k5qq5y3ABiBLkOfUPlk/FO9fpTFpF+jgs=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20241023133804-cedd67cf2652 h1:onyZbHYR1GJJOVd8iRtwVpgrowukWNl3EA0gWYRxixs=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20241023133804-cedd67cf2652/go.mod h1:nP+AtQWrc3k5qq5y3ABiBLkOfUPlk/FO9fpTFpF+jgs=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20241023182613-55984cdf5233 h1:Ea4HixNfDNDPh7zMngPpEeDf8gpociSPEROBFBedqIY=
|
||||
dev.mediocregopher.com/mediocre-go-lib.git v0.0.0-20241023182613-55984cdf5233/go.mod h1:nP+AtQWrc3k5qq5y3ABiBLkOfUPlk/FO9fpTFpF+jgs=
|
||||
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
||||
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
Loading…
Reference in New Issue
Block a user