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

Function TestCrateDBConnect

conn_test.go:25–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestCrateDBConnect(t *testing.T) {
26 t.Parallel()
27
28 connString := os.Getenv("PGX_TEST_CRATEDB_CONN_STRING")
29 if connString == "" {
30 t.Skipf("Skipping due to missing environment variable %v", "PGX_TEST_CRATEDB_CONN_STRING")
31 }
32
33 conn, err := pgx.Connect(context.Background(), connString)
34 require.Nil(t, err)
35 defer closeConn(t, conn)
36
37 assert.Equal(t, connString, conn.Config().ConnString())
38
39 var result int
40 err = conn.QueryRow(context.Background(), "select 1 +1").Scan(&result)
41 if err != nil {
42 t.Fatalf("QueryRow Scan unexpectedly failed: %v", err)
43 }
44 if result != 2 {
45 t.Errorf("bad result: %d", result)
46 }
47}
48
49func TestConnect(t *testing.T) {
50 t.Parallel()

Callers

nothing calls this directly

Calls 6

closeConnFunction · 0.70
ScanMethod · 0.65
QueryRowMethod · 0.65
ConnectMethod · 0.45
ConnStringMethod · 0.45
ConfigMethod · 0.45

Tested by

no test coverage detected