| 36 | ) |
| 37 | |
| 38 | func TestConnect(t *testing.T) { |
| 39 | tests := []struct { |
| 40 | name string |
| 41 | env string |
| 42 | }{ |
| 43 | {"Unix socket", "PGX_TEST_UNIX_SOCKET_CONN_STRING"}, |
| 44 | {"TCP", "PGX_TEST_TCP_CONN_STRING"}, |
| 45 | {"Plain password", "PGX_TEST_PLAIN_PASSWORD_CONN_STRING"}, |
| 46 | {"MD5 password", "PGX_TEST_MD5_PASSWORD_CONN_STRING"}, |
| 47 | {"SCRAM password", "PGX_TEST_SCRAM_PASSWORD_CONN_STRING"}, |
| 48 | } |
| 49 | |
| 50 | for _, tt := range tests { |
| 51 | t.Run(tt.name, func(t *testing.T) { |
| 52 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 53 | defer cancel() |
| 54 | |
| 55 | connString := os.Getenv(tt.env) |
| 56 | if connString == "" { |
| 57 | t.Skipf("Skipping due to missing environment variable %v", tt.env) |
| 58 | } |
| 59 | |
| 60 | conn, err := pgconn.Connect(ctx, connString) |
| 61 | require.NoError(t, err) |
| 62 | |
| 63 | closeConn(t, conn) |
| 64 | }) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func TestConnectWithOptions(t *testing.T) { |
| 69 | tests := []struct { |