Skip to content

Commit 2df5e52

Browse files
committed
chore: update credential tests
1 parent 149e1ee commit 2df5e52

3 files changed

Lines changed: 42 additions & 60 deletions

File tree

tests/mysql_test.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,42 +164,36 @@ func TestMySQLAuthentication(t *testing.T) {
164164
},
165165
}
166166
if *ipType == "public" {
167-
tcs = append(tcs,
168-
struct {
169-
desc string
170-
args []string
171-
}{
167+
additionaTcs := []struct {
168+
desc string
169+
args []string
170+
}{
171+
{
172172
desc: "with credentials file",
173173
args: []string{"--credentials-file", path, *mysqlConnName},
174174
},
175-
struct {
176-
desc string
177-
args []string
178-
}{
175+
{
179176
desc: "with credentials file and impersonation",
180177
args: []string{
181178
"--credentials-file", path,
182179
"--impersonate-service-account", *impersonatedUser,
183-
*mysqlConnName},
180+
*mysqlConnName,
181+
},
184182
},
185-
struct {
186-
desc string
187-
args []string
188-
}{
183+
{
189184
desc: "with credentials JSON",
190185
args: []string{"--json-credentials", string(creds), *mysqlConnName},
191186
},
192-
struct {
193-
desc string
194-
args []string
195-
}{
187+
{
196188
desc: "with credentials JSON and impersonation",
197189
args: []string{
198190
"--json-credentials", string(creds),
199191
"--impersonate-service-account", *impersonatedUser,
200-
*mysqlConnName},
192+
*mysqlConnName,
193+
},
201194
},
202-
)
195+
}
196+
tcs = append(tcs, additionaTcs...)
203197
}
204198
for _, tc := range tcs {
205199
t.Run(tc.desc, func(t *testing.T) {

tests/postgres_test.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,42 +148,36 @@ func TestPostgresAuthentication(t *testing.T) {
148148
},
149149
}
150150
if *ipType == "public" {
151-
tcs = append(tcs,
152-
[]struct {
153-
desc string
154-
args []string
155-
}{
151+
additionalTcs := []struct {
152+
desc string
153+
args []string
154+
}{
155+
{
156156
desc: "with credentials file",
157157
args: []string{"--credentials-file", path, *postgresConnName},
158158
},
159-
struct {
160-
desc string
161-
args []string
162-
}{
159+
{
163160
desc: "with credentials file and impersonation",
164161
args: []string{
165162
"--credentials-file", path,
166163
"--impersonate-service-account", *impersonatedUser,
167-
*postgresConnName},
164+
*postgresConnName,
165+
},
168166
},
169-
struct {
170-
desc string
171-
args []string
172-
}{
167+
{
173168
desc: "with credentials JSON",
174169
args: []string{"--json-credentials", string(creds), *postgresConnName},
175170
},
176-
struct {
177-
desc string
178-
args []string
179-
}{
171+
{
180172
desc: "with credentials JSON and impersonation",
181173
args: []string{
182174
"--json-credentials", string(creds),
183175
"--impersonate-service-account", *impersonatedUser,
184-
*postgresConnName},
176+
*postgresConnName,
177+
},
185178
},
186-
)
179+
}
180+
tcs = append(tcs, additionalTcs...)
187181
}
188182
for _, tc := range tcs {
189183
t.Run(tc.desc, func(t *testing.T) {

tests/sqlserver_test.go

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,42 +108,36 @@ func TestSQLServerAuthentication(t *testing.T) {
108108
},
109109
}
110110
if *ipType == "public" {
111-
tcs = append(tcs,
112-
[]struct {
113-
desc string
114-
args []string
115-
}{
111+
additionaTcs := []struct {
112+
desc string
113+
args []string
114+
}{
115+
{
116116
desc: "with credentials file",
117117
args: []string{"--credentials-file", path, *sqlserverConnName},
118118
},
119-
struct {
120-
desc string
121-
args []string
122-
}{
119+
{
123120
desc: "with credentials file and impersonation",
124121
args: []string{
125122
"--credentials-file", path,
126123
"--impersonate-service-account", *impersonatedUser,
127-
*sqlserverConnName},
124+
*sqlserverConnName,
125+
},
128126
},
129-
struct {
130-
desc string
131-
args []string
132-
}{
127+
{
133128
desc: "with credentials JSON",
134129
args: []string{"--json-credentials", string(creds), *sqlserverConnName},
135130
},
136-
struct {
137-
desc string
138-
args []string
139-
}{
131+
{
140132
desc: "with credentials JSON and impersonation",
141133
args: []string{
142134
"--json-credentials", string(creds),
143135
"--impersonate-service-account", *impersonatedUser,
144-
*sqlserverConnName},
136+
*sqlserverConnName,
137+
},
145138
},
146-
)
139+
}
140+
tcs = append(tcs, additionaTcs...)
147141
}
148142
for _, tc := range tcs {
149143
t.Run(tc.desc, func(t *testing.T) {

0 commit comments

Comments
 (0)