MCPcopy Create free account
hub / github.com/LissaGreense/GO4SQL / TestSelectWithLimitCommand

Function TestSelectWithLimitCommand

parser/parser_test.go:360–391  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

358}
359
360func 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
393func TestSelectWithOffsetCommand(t *testing.T) {
394 input := "SELECT * FROM tableName OFFSET 5;"

Callers

nothing calls this directly

Calls 6

RunLexerFunction · 0.92
testSelectStatementFunction · 0.85
testLimitCommandsFunction · 0.85
ParseSequenceMethod · 0.80
HasLimitCommandMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected