(t *testing.T)
| 321 | } |
| 322 | |
| 323 | func TestSelectWithOrderByCommand(t *testing.T) { |
| 324 | input := "SELECT * FROM tableName ORDER BY colName1 DESC;" |
| 325 | expectedSortPattern := ast.SortPattern{ |
| 326 | ColumnName: token.Token{Type: token.IDENT, Literal: "colName1"}, |
| 327 | Order: token.Token{Type: token.DESC, Literal: "DESC"}, |
| 328 | } |
| 329 | expectedOrderByCommand := ast.OrderByCommand{ |
| 330 | Token: token.Token{Type: token.ORDER, Literal: "ORDER"}, |
| 331 | SortPatterns: []ast.SortPattern{expectedSortPattern}, |
| 332 | } |
| 333 | expectedTableName := "tableName" |
| 334 | expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.ASTERISK, Literal: "*"}}} |
| 335 | |
| 336 | lexer := lexer.RunLexer(input) |
| 337 | parserInstance := New(lexer) |
| 338 | sequences, err := parserInstance.ParseSequence() |
| 339 | if err != nil { |
| 340 | t.Fatalf("Got error from parser: %s", err) |
| 341 | } |
| 342 | |
| 343 | if len(sequences.Commands) != 1 { |
| 344 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 345 | } |
| 346 | |
| 347 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 348 | |
| 349 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) { |
| 350 | return |
| 351 | } |
| 352 | |
| 353 | if !selectCommand.HasOrderByCommand() { |
| 354 | t.Fatalf("sequences does not contain where command") |
| 355 | } |
| 356 | |
| 357 | testOrderByCommands(t, expectedOrderByCommand, selectCommand.OrderByCommand) |
| 358 | } |
| 359 | |
| 360 | func TestSelectWithLimitCommand(t *testing.T) { |
| 361 | input := "SELECT * FROM tableName LIMIT 5;" |
nothing calls this directly
no test coverage detected