MCPcopy Index your code
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestNewCommandArguments

Function TestNewCommandArguments

cmd/root_test.go:133–513  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestNewCommandArguments(t *testing.T) {
134 tcs := []struct {
135 desc string
136 args []string
137 want *proxy.Config
138 }{
139 {
140 desc: "basic invocation with defaults",
141 args: []string{"proj:region:inst"},
142 want: withDefaults(&proxy.Config{
143 Addr: "127.0.0.1",
144 Instances: []proxy.InstanceConnConfig{{Name: "proj:region:inst"}},
145 }),
146 },
147 {
148 desc: "using the address flag",
149 args: []string{"--address", "0.0.0.0", "proj:region:inst"},
150 want: withDefaults(&proxy.Config{
151 Addr: "0.0.0.0",
152 Instances: []proxy.InstanceConnConfig{{Name: "proj:region:inst"}},
153 }),
154 },
155 {
156 desc: "using the address (short) flag",
157 args: []string{"-a", "0.0.0.0", "proj:region:inst"},
158 want: withDefaults(&proxy.Config{
159 Addr: "0.0.0.0",
160 Instances: []proxy.InstanceConnConfig{{Name: "proj:region:inst"}},
161 }),
162 },
163 {
164 desc: "using the address query param",
165 args: []string{"proj:region:inst?address=0.0.0.0"},
166 want: withDefaults(&proxy.Config{
167 Addr: "127.0.0.1",
168 Instances: []proxy.InstanceConnConfig{{
169 Addr: "0.0.0.0",
170 Name: "proj:region:inst",
171 }},
172 }),
173 },
174 {
175 desc: "using the port flag",
176 args: []string{"--port", "6000", "proj:region:inst"},
177 want: withDefaults(&proxy.Config{
178 Port: 6000,
179 }),
180 },
181 {
182 desc: "using the port (short) flag",
183 args: []string{"-p", "6000", "proj:region:inst"},
184 want: withDefaults(&proxy.Config{
185 Port: 6000,
186 }),
187 },
188 {
189 desc: "using the port query param",
190 args: []string{"proj:region:inst?port=6000"},

Callers

nothing calls this directly

Calls 3

withDefaultsFunction · 0.85
invokeProxyCommandFunction · 0.85
pointerFunction · 0.70

Tested by

no test coverage detected