|
32 | 32 | postgresPass = flag.String("postgres_pass", os.Getenv("POSTGRES_PASS"), "Password for the database user; be careful when entering a password on the command line (it may go into your terminal's history).") |
33 | 33 | postgresDB = flag.String("postgres_db", os.Getenv("POSTGRES_DB"), "Name of the database to connect to.") |
34 | 34 | postgresIAMUser = flag.String("postgres_user_iam", os.Getenv("POSTGRES_USER_IAM"), "Name of database user configured with IAM DB Authentication.") |
| 35 | + postgresMCPConnName = flag.String("postgres_mcp_conn_name", os.Getenv("POSTGRES_MCP_CONNECTION_NAME"), "Cloud SQL Postgres instance connection name for a managed instance, in the form of 'project:region:instance'.") |
| 36 | + postgresMCPPass = flag.String("postgres_mcp_pass", os.Getenv("POSTGRES_MCP_PASS"), "Password for the managed instance database user; be careful when entering a password on the command line (it may go into your terminal's history).") |
35 | 37 | postgresCustomerCASConnName = flag.String("postgres_customer_cas_conn_name", os.Getenv("POSTGRES_CUSTOMER_CAS_CONNECTION_NAME"), "Cloud SQL Postgres instance connection name for a customer CAS enabled instance, in the form of 'project:region:instance'.") |
36 | 38 | postgresCustomerCASPass = flag.String("postgres_customer_cas_pass", os.Getenv("POSTGRES_CUSTOMER_CAS_PASS"), "Password for the customer CAS instance database user; be careful when entering a password on the command line (it may go into your terminal's history).") |
37 | 39 | postgresCustomerCASDomain = flag.String("postgres_customer_cas_domain", os.Getenv("POSTGRES_CUSTOMER_CAS_DOMAIN_NAME"), "Valid DNS domain name for the customer CAS instance.") |
@@ -90,6 +92,28 @@ func TestPostgresUnix(t *testing.T) { |
90 | 92 | proxyConnTest(t, args, "pgx", dsn) |
91 | 93 | } |
92 | 94 |
|
| 95 | +func 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 | + |
93 | 117 | func createTempDir(t *testing.T) (string, func()) { |
94 | 118 | testDir, err := os.MkdirTemp("", "*") |
95 | 119 | if err != nil { |
|
0 commit comments