From 75a64d981796df0717411b1c288a2e1739a832d5 Mon Sep 17 00:00:00 2001 From: Ben Wright Date: Mon, 27 May 2024 17:41:12 +0100 Subject: [PATCH] tweaks --- deploy/Test.Dockerfile | 2 +- tests/nats_test.go | 7 +++++++ tests/postgres_test.go | 13 ++++++++++++- tests/redis_test.go | 7 +++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/deploy/Test.Dockerfile b/deploy/Test.Dockerfile index f3d1940..0b5d9de 100644 --- a/deploy/Test.Dockerfile +++ b/deploy/Test.Dockerfile @@ -3,4 +3,4 @@ FROM scratch COPY tests /tests ENTRYPOINT [ "/tests" ] -CMD [ "-test.run", "Integration", "-test.v" ] \ No newline at end of file +CMD [ "-test.run", "Integration" ] \ No newline at end of file diff --git a/tests/nats_test.go b/tests/nats_test.go index 7ced454..95d6c4c 100644 --- a/tests/nats_test.go +++ b/tests/nats_test.go @@ -8,6 +8,7 @@ import ( "github.com/benjamin-wright/db-operator/internal/dbs/nats/k8s" "github.com/benjamin-wright/db-operator/internal/dbs/nats/k8s/clients" "github.com/benjamin-wright/db-operator/internal/dbs/nats/k8s/clusters" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" ) @@ -16,6 +17,12 @@ func TestNatsIntegration(t *testing.T) { t.Skip("skipping integration test") } + if testing.Verbose() { + zerolog.SetGlobalLevel(zerolog.DebugLevel) + } else { + zerolog.SetGlobalLevel(zerolog.Disabled) + } + namespace := os.Getenv("NAMESPACE") client, err := k8s.New() diff --git a/tests/postgres_test.go b/tests/postgres_test.go index 84fc69d..d1fbdd5 100644 --- a/tests/postgres_test.go +++ b/tests/postgres_test.go @@ -104,6 +104,17 @@ func TestPostgresIntegration(t *testing.T) { mustPass(t, err) mustPass(t, mig.Init()) + mustPass(t, mig.Run([]migrations.Migration{ + { + Index: 1, + Query: ` + CREATE TABLE test_table ( + id SERIAL PRIMARY KEY, + name VARCHAR(255) NOT NULL + ) + `, + }, + })) user := waitForResult(t, func() (secrets.Resource, error) { return client.Secrets().Get(context.Background(), "other-secret-"+seed, namespace) @@ -123,6 +134,6 @@ func TestPostgresIntegration(t *testing.T) { tables := pg.GetTableNames(t) - expected := []string{"migrations"} + expected := []string{"migrations", "test_table"} assert.Equal(t, expected, tables) } diff --git a/tests/redis_test.go b/tests/redis_test.go index 6490877..614bb36 100644 --- a/tests/redis_test.go +++ b/tests/redis_test.go @@ -8,6 +8,7 @@ import ( "github.com/benjamin-wright/db-operator/internal/dbs/redis/k8s" "github.com/benjamin-wright/db-operator/internal/dbs/redis/k8s/clients" "github.com/benjamin-wright/db-operator/internal/dbs/redis/k8s/clusters" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" ) @@ -16,6 +17,12 @@ func TestRedisIntegration(t *testing.T) { t.Skip("skipping integration test") } + if testing.Verbose() { + zerolog.SetGlobalLevel(zerolog.DebugLevel) + } else { + zerolog.SetGlobalLevel(zerolog.Disabled) + } + namespace := os.Getenv("NAMESPACE") client, err := k8s.New()