(t *testing.T)
| 1088 | } |
| 1089 | |
| 1090 | func TestSQLDataQueryParams(t *testing.T) { |
| 1091 | tcs := []struct { |
| 1092 | desc string |
| 1093 | args []string |
| 1094 | want *bool |
| 1095 | }{ |
| 1096 | { |
| 1097 | desc: "when the query string is absent", |
| 1098 | args: []string{"proj:region:inst"}, |
| 1099 | want: nil, |
| 1100 | }, |
| 1101 | { |
| 1102 | desc: "when the query string is true", |
| 1103 | args: []string{"proj:region:inst?sql-data=true"}, |
| 1104 | want: pointer(true), |
| 1105 | }, |
| 1106 | { |
| 1107 | desc: "when the query string is false", |
| 1108 | args: []string{"proj:region:inst?sql-data=false"}, |
| 1109 | want: pointer(false), |
| 1110 | }, |
| 1111 | } |
| 1112 | for _, tc := range tcs { |
| 1113 | t.Run(tc.desc, func(t *testing.T) { |
| 1114 | c, err := invokeProxyCommand(tc.args) |
| 1115 | if err != nil { |
| 1116 | t.Fatalf("command.Execute: %v", err) |
| 1117 | } |
| 1118 | if tc.want == nil { |
| 1119 | if len(c.conf.Instances) > 0 && c.conf.Instances[0].SQLDataEnabled != nil { |
| 1120 | t.Fatalf("args = %v, want nil, got = %v", tc.args, *c.conf.Instances[0].SQLDataEnabled) |
| 1121 | } |
| 1122 | return |
| 1123 | } |
| 1124 | if len(c.conf.Instances) == 0 { |
| 1125 | t.Fatal("expected at least one instance") |
| 1126 | } |
| 1127 | got := c.conf.Instances[0].SQLDataEnabled |
| 1128 | if got == nil { |
| 1129 | t.Fatalf("args = %v, want = %v, got = nil", tc.args, *tc.want) |
| 1130 | } |
| 1131 | if *got != *tc.want { |
| 1132 | t.Errorf("args = %v, want = %v, got = %v", tc.args, *tc.want, *got) |
| 1133 | } |
| 1134 | }) |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | func TestNewCommandWithErrors(t *testing.T) { |
| 1139 | tcs := []struct { |
nothing calls this directly
no test coverage detected