-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: WithLogger ContainerCustomizer support
Add support to use WithLogger as a ContainerCustomizer so that callers have an easy way to configure the logger of a container. Add tests for WithLogger. Validate Logger and LoggerOption implement the required interfaces.
- Loading branch information
Showing
3 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package testcontainers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestWithLogger(t *testing.T) { | ||
logger := TestLogger(t) | ||
logOpt := WithLogger(logger) | ||
t.Run("container", func(t *testing.T) { | ||
var req GenericContainerRequest | ||
logOpt.Customize(&req) | ||
require.Equal(t, logger, req.Logger) | ||
}) | ||
|
||
t.Run("provider", func(t *testing.T) { | ||
var opts GenericProviderOptions | ||
logOpt.ApplyGenericTo(&opts) | ||
require.Equal(t, logger, opts.Logger) | ||
}) | ||
|
||
t.Run("docker", func(t *testing.T) { | ||
opts := &DockerProviderOptions{ | ||
GenericProviderOptions: &GenericProviderOptions{}, | ||
} | ||
logOpt.ApplyDockerTo(opts) | ||
require.Equal(t, logger, opts.Logger) | ||
}) | ||
} |