MCPcopy
hub / github.com/jackc/pgx / TestConnectWithOptions

Function TestConnectWithOptions

pgconn/pgconn_test.go:68–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func 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.

Callers

nothing calls this directly

Calls 3

ConnectWithOptionsFunction · 0.92
closeConnFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected