Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/server/internal/container/container_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package container

import (
"context"
"testing"

"github.com/jackc/pgx/v5/pgxpool"
"github.com/stretchr/testify/assert"
)

func TestContainer_Close(t *testing.T) {
// Create a dummy pool
config, err := pgxpool.ParseConfig("postgres://localhost:5432/postgres")
assert.NoError(t, err)

pool, err := pgxpool.NewWithConfig(context.Background(), config)
assert.NoError(t, err)

// Create a container with the dummy pool
c := &Container{
DB: pool,
}

// Call Close and assert no error
err = c.Close()
assert.NoError(t, err)

// Additional verification: we can't easily check if pool is closed directly
// without calling a method that requires it to be open, or relying on internals.
// We can try to Ping it. It should fail since the pool is closed.
err = pool.Ping(context.Background())
assert.Error(t, err)
assert.Contains(t, err.Error(), "closed pool")
}
Loading