(t *testing.T)
| 200 | } |
| 201 | |
| 202 | func TestCreateViewFields(t *testing.T) { |
| 203 | t.Parallel() |
| 204 | |
| 205 | app, _ := tests.NewTestApp() |
| 206 | defer app.Cleanup() |
| 207 | |
| 208 | scenarios := []struct { |
| 209 | name string |
| 210 | query string |
| 211 | expectError bool |
| 212 | expectFields map[string]string // name-type pairs |
| 213 | }{ |
| 214 | { |
| 215 | "empty query", |
| 216 | "", |
| 217 | true, |
| 218 | nil, |
| 219 | }, |
| 220 | { |
| 221 | "invalid query", |
| 222 | "test 123456", |
| 223 | true, |
| 224 | nil, |
| 225 | }, |
| 226 | { |
| 227 | "missing table", |
| 228 | "select id from missing", |
| 229 | true, |
| 230 | nil, |
| 231 | }, |
| 232 | { |
| 233 | "query with wildcard column", |
| 234 | "select a.id, a.* from demo1 a", |
| 235 | true, |
| 236 | nil, |
| 237 | }, |
| 238 | { |
| 239 | "query without id", |
| 240 | "select text, url, created, updated from demo1", |
| 241 | true, |
| 242 | nil, |
| 243 | }, |
| 244 | { |
| 245 | "query with comments", |
| 246 | ` |
| 247 | select |
| 248 | -- test single line |
| 249 | demo1.id, |
| 250 | demo1.text, |
| 251 | /* multi |
| 252 | * line comment block */ |
| 253 | demo1.url, demo1.created, demo1.updated from/* inline comment block with no spaces between the identifiers */demo1 |
| 254 | -- comment before join |
| 255 | join demo2 ON ( |
| 256 | -- comment inside join |
| 257 | demo2.id = demo1.id |
| 258 | ) |
| 259 | -- comment before where |
nothing calls this directly
no test coverage detected
searching dependent graphs…