-
Notifications
You must be signed in to change notification settings - Fork 178
Currently, the River log example looks like this:
riverlog.Logger(ctx).Info("Logged from worker")
If I want to write unit tests for this code, how do I get a context with a logger attached? I couldn't find an easy way to do this in the current API.
All reactions
Test workers through the rivertest.NewWorker interface, which will add the logger context and a few other things to make the runs look as realistic as possible (make sure to include the logging middleware in the injected NewWorker config). See docs here:
https://riverqueue.com/docs/testing#using-the-rivertestworker-helpers
Replies: 1 comment
Test workers through the rivertest.NewWorker interface, which will add the logger context and a few other things to make the runs look as realistic as possible (make sure to include the logging middleware in the injected NewWorker config). See docs here:
https://riverqueue.com/docs/testing#using-the-rivertestworker-helpers