github.com/supabase/cli@v1.168.1/internal/debug/postgres_test.go (about) 1 package debug 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/jackc/pgx/v4" 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 "github.com/supabase/cli/internal/testing/pgtest" 11 ) 12 13 func TestPostgresProxy(t *testing.T) { 14 const postgresUrl = "postgresql://postgres:password@127.0.0.1:5432/postgres" 15 16 t.Run("forwards messages between frontend and backend", func(t *testing.T) { 17 // Parse connection url 18 config, err := pgx.ParseConfig(postgresUrl) 19 require.NoError(t, err) 20 // Setup postgres mock 21 conn := pgtest.NewConn() 22 defer conn.Close(t) 23 conn.Intercept(config) 24 // Run test 25 SetupPGX(config) 26 ctx := context.Background() 27 proxy, err := pgx.ConnectConfig(ctx, config) 28 assert.NoError(t, err) 29 assert.NoError(t, proxy.Close(ctx)) 30 }) 31 }