(t *testing.T)
| 358 | } |
| 359 | |
| 360 | func TestSelectWithLimitCommand(t *testing.T) { |
| 361 | input := "SELECT * FROM tableName LIMIT 5;" |
| 362 | expectedLimitCommand := ast.LimitCommand{ |
| 363 | Token: token.Token{Type: token.LIMIT, Literal: "LIMIT"}, |
| 364 | Count: 5, |
| 365 | } |
| 366 | expectedTableName := "tableName" |
| 367 | expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.ASTERISK, Literal: "*"}}} |
| 368 | |
| 369 | lexer := lexer.RunLexer(input) |
| 370 | parserInstance := New(lexer) |
| 371 | sequences, err := parserInstance.ParseSequence() |
| 372 | if err != nil { |
| 373 | t.Fatalf("Got error from parser: %s", err) |
| 374 | } |
| 375 | |
| 376 | if len(sequences.Commands) != 1 { |
| 377 | t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands)) |
| 378 | } |
| 379 | |
| 380 | selectCommand := sequences.Commands[0].(*ast.SelectCommand) |
| 381 | |
| 382 | if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) { |
| 383 | return |
| 384 | } |
| 385 | |
| 386 | if !selectCommand.HasLimitCommand() { |
| 387 | t.Fatalf("sequences does not contain where command") |
| 388 | } |
| 389 | |
| 390 | testLimitCommands(t, expectedLimitCommand, selectCommand.LimitCommand) |
| 391 | } |
| 392 | |
| 393 | func TestSelectWithOffsetCommand(t *testing.T) { |
| 394 | input := "SELECT * FROM tableName OFFSET 5;" |
nothing calls this directly
no test coverage detected