diff options
Diffstat (limited to 'test/integration')
| -rw-r--r-- | test/integration/container.go | 4 | ||||
| -rw-r--r-- | test/integration/log_consumer.go | 16 | ||||
| -rw-r--r-- | test/integration/logger.go | 15 | ||||
| -rw-r--r-- | test/integration/oidc.go | 27 |
4 files changed, 18 insertions, 44 deletions
diff --git a/test/integration/container.go b/test/integration/container.go index 651fcf5..0a210dd 100644 --- a/test/integration/container.go +++ b/test/integration/container.go @@ -10,6 +10,7 @@ import ( "github.com/docker/go-connections/nat" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/log" "github.com/testcontainers/testcontainers-go/wait" "github.com/xlgmokha/x/pkg/env" "github.com/xlgmokha/x/pkg/x" @@ -21,7 +22,8 @@ func NewContainer(t *testing.T, ctx context.Context, envVars map[string]string) ctx, env.Fetch("IMAGE_TAG", "sparkled:invalid"), testcontainers.WithEnv(envVars), - testcontainers.WithLogConsumers(&LogConsumer{t: t}), + testcontainers.WithLogConsumers(&Logger{TB: t}), + testcontainers.WithLogger(log.TestLogger(t)), testcontainers.WithWaitStrategy( wait.ForLog("Listening on"), wait.ForListeningPort(x.Must(nat.NewPort("tcp", "10000"))), diff --git a/test/integration/log_consumer.go b/test/integration/log_consumer.go deleted file mode 100644 index 4af438f..0000000 --- a/test/integration/log_consumer.go +++ /dev/null @@ -1,16 +0,0 @@ -package test - -import ( - "testing" - - "github.com/testcontainers/testcontainers-go" -) - -type LogConsumer struct { - t *testing.T -} - -func (lc *LogConsumer) Accept(l testcontainers.Log) { - content := string(l.Content) - lc.t.Logf("%s", content) -} diff --git a/test/integration/logger.go b/test/integration/logger.go new file mode 100644 index 0000000..86660bc --- /dev/null +++ b/test/integration/logger.go @@ -0,0 +1,15 @@ +package test + +import ( + "testing" + + "github.com/testcontainers/testcontainers-go" +) + +type Logger struct { + testing.TB +} + +func (t *Logger) Accept(l testcontainers.Log) { + t.Logf("%s", l.Content) +} diff --git a/test/integration/oidc.go b/test/integration/oidc.go deleted file mode 100644 index 35653ef..0000000 --- a/test/integration/oidc.go +++ /dev/null @@ -1,27 +0,0 @@ -package test - -import ( - "net" - "net/http" - "testing" - - "github.com/oauth2-proxy/mockoidc" - "github.com/stretchr/testify/require" -) - -func NewOIDCTestServer(t *testing.T) *mockoidc.MockOIDC { - srv, err := mockoidc.NewServer(nil) - require.NoError(t, err) - - srv.AddMiddleware(func(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - t.Logf("%v %v %v\n", r.Method, r.URL.Path, r.URL.Query()) - next.ServeHTTP(w, r) - }) - }) - - ln, err := net.Listen("tcp4", "0.0.0.0:0") - require.NoError(t, err) - require.NoError(t, srv.Start(ln, nil)) - return srv -} |
