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

Function TestParseDropCommand

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

Source from the content-addressed store, hash-verified

289}
290
291func TestParseDropCommand(t *testing.T) {
292 input := "DROP TABLE table;"
293 expectedDropCommand := ast.DropCommand{
294 Token: token.Token{Type: token.DROP, Literal: "DROP"},
295 Name: ast.Identifier{Token: token.Token{Type: token.IDENT, Literal: "table"}},
296 }
297
298 lexer := lexer.RunLexer(input)
299 parserInstance := New(lexer)
300 sequences, err := parserInstance.ParseSequence()
301 if err != nil {
302 t.Fatalf("Got error from parser: %s", err)
303 }
304
305 if len(sequences.Commands) != 1 {
306 t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands))
307 }
308
309 actualDropCommand, ok := sequences.Commands[0].(*ast.DropCommand)
310 if !ok {
311 t.Errorf("actualDropCommand is not %T. got=%T", &ast.DropCommand{}, sequences.Commands[0])
312 }
313
314 if expectedDropCommand.TokenLiteral() != actualDropCommand.TokenLiteral() {
315 t.Errorf("TokenLiteral of DropCommand is not %s. got=%s", expectedDropCommand.TokenLiteral(), actualDropCommand.TokenLiteral())
316 }
317
318 if expectedDropCommand.Name.GetToken().Literal != actualDropCommand.Name.GetToken().Literal {
319 t.Errorf("Table name of DropCommand is not %s. got=%s", expectedDropCommand.Name.GetToken().Literal, actualDropCommand.Name.GetToken().Literal)
320 }
321}
322
323func TestSelectWithOrderByCommand(t *testing.T) {
324 input := "SELECT * FROM tableName ORDER BY colName1 DESC;"

Callers

nothing calls this directly

Calls 6

TokenLiteralMethod · 0.95
RunLexerFunction · 0.92
ParseSequenceMethod · 0.80
NewFunction · 0.70
TokenLiteralMethod · 0.65
GetTokenMethod · 0.65

Tested by

no test coverage detected