Skip to content

Commit 863146e

Browse files
committed
chore: reformat tests
1 parent 5120ca0 commit 863146e

3 files changed

Lines changed: 18 additions & 38 deletions

File tree

tests/mysql_test.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,14 @@ func mysqlDSN() string {
6262
return cfg.FormatDSN()
6363
}
6464

65-
// addIPTypeFlag appends the correct flag based on the ipType variable.
66-
func addIPTypeFlag(args []string) []string {
65+
// AddIPTypeFlag appends the correct flag based on the ipType variable.
66+
func AddIPTypeFlag(args []string) []string {
6767
switch *ipType {
6868
case "private":
6969
return append(args, "--private-ip")
7070
case "psc":
7171
return append(args, "--psc")
72-
// "public" is the default and doesn't require a flag
73-
case "public":
74-
return args
7572
default:
76-
// Or handle unknown ipType values as needed, maybe log a warning?
7773
return args
7874
}
7975
}
@@ -86,7 +82,7 @@ func TestMySQLTCP(t *testing.T) {
8682
// Prepare the initial arguments
8783
args := []string{*mysqlConnName}
8884
// Add the IP type flag using the helper
89-
args = addIPTypeFlag(args)
85+
args = AddIPTypeFlag(args)
9086
// Run the test
9187
proxyConnTest(t, args, "mysql", mysqlDSN())
9288
}
@@ -112,7 +108,7 @@ func TestMySQLUnix(t *testing.T) {
112108
// Prepare the initial arguments
113109
args := []string{"--unix-socket", tmpDir, *mysqlConnName}
114110
// Add the IP type flag using the helper
115-
args = addIPTypeFlag(args)
111+
args = AddIPTypeFlag(args)
116112
// Run the test
117113
proxyConnTest(t, args, "mysql", cfg.FormatDSN())
118114
}
@@ -129,7 +125,7 @@ func TestMySQLImpersonation(t *testing.T) {
129125
*mysqlConnName,
130126
}
131127
// Add the IP type flag using the helper
132-
args = addIPTypeFlag(args)
128+
args = AddIPTypeFlag(args)
133129
// Run the test
134130
proxyConnTest(t, args, "mysql", mysqlDSN())
135131
}
@@ -197,9 +193,7 @@ func TestMySQLAuthentication(t *testing.T) {
197193
}
198194
for _, tc := range tcs {
199195
t.Run(tc.desc, func(t *testing.T) {
200-
// Add the IP type flag using the helper
201-
argsWithIPType := addIPTypeFlag(tc.args)
202-
proxyConnTest(t, argsWithIPType, "mysql", mysqlDSN())
196+
proxyConnTest(t, AddIPTypeFlag(tc.args), "mysql", mysqlDSN())
203197
})
204198
}
205199
}
@@ -231,9 +225,7 @@ func TestMySQLGcloudAuth(t *testing.T) {
231225
}
232226
for _, tc := range tcs {
233227
t.Run(tc.desc, func(t *testing.T) {
234-
// Add the IP type flag using the helper
235-
argsWithIPType := addIPTypeFlag(tc.args)
236-
proxyConnTest(t, argsWithIPType, "mysql", mysqlDSN())
228+
proxyConnTest(t, AddIPTypeFlag(tc.args), "mysql", mysqlDSN())
237229
})
238230
}
239231
}

tests/postgres_test.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestPostgresTCP(t *testing.T) {
6363
// Prepare the initial arguments
6464
args := []string{*postgresConnName}
6565
// Add the IP type flag using the helper
66-
args = addIPTypeFlag(args)
66+
args = AddIPTypeFlag(args)
6767
// Run the test
6868
proxyConnTest(t, args, "pgx", postgresDSN())
6969
}
@@ -85,7 +85,7 @@ func TestPostgresUnix(t *testing.T) {
8585
// Prepare the initial arguments
8686
args := []string{"--unix-socket", tmpDir, *postgresConnName}
8787
// Add the IP type flag using the helper
88-
args = addIPTypeFlag(args)
88+
args = AddIPTypeFlag(args)
8989
// Run the test
9090
proxyConnTest(t, args, "pgx", dsn)
9191
}
@@ -113,7 +113,7 @@ func TestPostgresImpersonation(t *testing.T) {
113113
*postgresConnName,
114114
}
115115
// Add the IP type flag using the helper
116-
args = addIPTypeFlag(args)
116+
args = AddIPTypeFlag(args)
117117
// Run the test
118118
proxyConnTest(t, args, "pgx", postgresDSN())
119119
}
@@ -181,9 +181,7 @@ func TestPostgresAuthentication(t *testing.T) {
181181
}
182182
for _, tc := range tcs {
183183
t.Run(tc.desc, func(t *testing.T) {
184-
// Add the IP type flag using the helper
185-
argsWithIPType := addIPTypeFlag(tc.args)
186-
proxyConnTest(t, argsWithIPType, "pgx", postgresDSN())
184+
proxyConnTest(t, AddIPTypeFlag(tc.args), "pgx", postgresDSN())
187185
})
188186
}
189187
}
@@ -215,9 +213,7 @@ func TestPostgresGcloudAuth(t *testing.T) {
215213
}
216214
for _, tc := range tcs {
217215
t.Run(tc.desc, func(t *testing.T) {
218-
// Add the IP type flag using the helper
219-
argsWithIPType := addIPTypeFlag(tc.args)
220-
proxyConnTest(t, argsWithIPType, "pgx", postgresDSN())
216+
proxyConnTest(t, AddIPTypeFlag(tc.args), "pgx", postgresDSN())
221217
})
222218
}
223219

@@ -263,9 +259,7 @@ func TestPostgresIAMDBAuthn(t *testing.T) {
263259
}
264260
for _, tc := range tcs {
265261
t.Run(tc.desc, func(t *testing.T) {
266-
// Add the IP type flag using the helper
267-
argsWithIPType := addIPTypeFlag(tc.args)
268-
proxyConnTest(t, argsWithIPType, "pgx", tc.dsn)
262+
proxyConnTest(t, AddIPTypeFlag(tc.args), "pgx", tc.dsn)
269263
})
270264
}
271265
}
@@ -306,9 +300,7 @@ func TestPostgresCustomerCAS(t *testing.T) {
306300
}
307301
for _, tc := range tcs {
308302
t.Run(tc.desc, func(t *testing.T) {
309-
// Add the IP type flag using the helper
310-
argsWithIPType := addIPTypeFlag(tc.args)
311-
proxyConnTest(t, argsWithIPType, "pgx", tc.dsn)
303+
proxyConnTest(t, AddIPTypeFlag(tc.args), "pgx", tc.dsn)
312304
})
313305
}
314306
}

tests/sqlserver_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestSQLServerTCP(t *testing.T) {
5757
// Prepare the initial arguments
5858
args := []string{*sqlserverConnName}
5959
// Add the IP type flag using the helper
60-
args = addIPTypeFlag(args)
60+
args = AddIPTypeFlag(args)
6161
// Run the test
6262
proxyConnTest(t, args, "sqlserver", sqlserverDSN())
6363
}
@@ -73,7 +73,7 @@ func TestSQLServerImpersonation(t *testing.T) {
7373
*sqlserverConnName,
7474
}
7575
// Add the IP type flag using the helper
76-
args = addIPTypeFlag(args)
76+
args = AddIPTypeFlag(args)
7777
// Run the test
7878
proxyConnTest(t, args, "sqlserver", sqlserverDSN())
7979
}
@@ -141,9 +141,7 @@ func TestSQLServerAuthentication(t *testing.T) {
141141
}
142142
for _, tc := range tcs {
143143
t.Run(tc.desc, func(t *testing.T) {
144-
// Add the IP type flag using the helper
145-
argsWithIPType := addIPTypeFlag(tc.args)
146-
proxyConnTest(t, argsWithIPType, "sqlserver", sqlserverDSN())
144+
proxyConnTest(t, AddIPTypeFlag(tc.args), "sqlserver", sqlserverDSN())
147145
})
148146
}
149147
}
@@ -175,9 +173,7 @@ func TestSQLServerGcloudAuth(t *testing.T) {
175173
}
176174
for _, tc := range tcs {
177175
t.Run(tc.desc, func(t *testing.T) {
178-
// Add the IP type flag using the helper
179-
argsWithIPType := addIPTypeFlag(tc.args)
180-
proxyConnTest(t, argsWithIPType, "sqlserver", sqlserverDSN())
176+
proxyConnTest(t, AddIPTypeFlag(tc.args), "sqlserver", sqlserverDSN())
181177
})
182178
}
183179
}

0 commit comments

Comments
 (0)