MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestPostgresMCPUnix

Function TestPostgresMCPUnix

tests/postgres_test.go:95–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestPostgresMCPUnix(t *testing.T) {
96 if testing.Short() {
97 t.Skip("skipping Postgres integration tests")
98 }
99 requirePostgresVars(t)
100 tmpDir, cleanup := createTempDir(t)
101 defer cleanup()
102
103 dsn := fmt.Sprintf("host=%s user=%s password=%s database=%s sslmode=disable",
104 // re-use utility function to determine the Unix address in a
105 // Windows-friendly way.
106 proxy.UnixAddress(tmpDir, *postgresMCPConnName),
107 *postgresUser, *postgresMCPPass, *postgresDB)
108
109 // Prepare the initial arguments
110 args := []string{"--unix-socket", tmpDir, *postgresMCPConnName}
111 // Add the IP type flag using the helper
112 args = AddIPTypeFlag(args)
113 // Run the test
114 proxyConnTest(t, args, "pgx", dsn)
115}
116
117func createTempDir(t *testing.T) (string, func()) {
118 testDir, err := os.MkdirTemp("", "*")

Callers

nothing calls this directly

Calls 5

UnixAddressFunction · 0.92
requirePostgresVarsFunction · 0.85
AddIPTypeFlagFunction · 0.85
proxyConnTestFunction · 0.85
createTempDirFunction · 0.70

Tested by

no test coverage detected