(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestConnectWithOptions(t *testing.T) { |
| 69 | tests := []struct { |
| 70 | name string |
| 71 | env string |
| 72 | }{ |
| 73 | {"Unix socket", "PGX_TEST_UNIX_SOCKET_CONN_STRING"}, |
| 74 | {"TCP", "PGX_TEST_TCP_CONN_STRING"}, |
| 75 | {"Plain password", "PGX_TEST_PLAIN_PASSWORD_CONN_STRING"}, |
| 76 | {"MD5 password", "PGX_TEST_MD5_PASSWORD_CONN_STRING"}, |
| 77 | {"SCRAM password", "PGX_TEST_SCRAM_PASSWORD_CONN_STRING"}, |
| 78 | } |
| 79 | |
| 80 | for _, tt := range tests { |
| 81 | t.Run(tt.name, func(t *testing.T) { |
| 82 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 83 | defer cancel() |
| 84 | |
| 85 | connString := os.Getenv(tt.env) |
| 86 | if connString == "" { |
| 87 | t.Skipf("Skipping due to missing environment variable %v", tt.env) |
| 88 | } |
| 89 | var sslOptions pgconn.ParseConfigOptions |
| 90 | sslOptions.GetSSLPassword = GetSSLPassword |
| 91 | conn, err := pgconn.ConnectWithOptions(ctx, connString, sslOptions) |
| 92 | require.NoError(t, err) |
| 93 | |
| 94 | closeConn(t, conn) |
| 95 | }) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // TestConnectTLS is separate from other connect tests because it has an additional test to ensure it really is a secure |
| 100 | // connection. |
nothing calls this directly
no test coverage detected