(t *testing.T)
| 289 | } |
| 290 | |
| 291 | func 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 | |
| 323 | func TestSelectWithOrderByCommand(t *testing.T) { |
| 324 | input := "SELECT * FROM tableName ORDER BY colName1 DESC;" |
nothing calls this directly
no test coverage detected