─── SELECT ──────────────────────────────────────────────────────────────────
(t *testing.T)
| 37 | // ─── SELECT ────────────────────────────────────────────────────────────────── |
| 38 | |
| 39 | func TestRenderSelect_Compact(t *testing.T) { |
| 40 | stmt := &ast.SelectStatement{ |
| 41 | Columns: []ast.Expression{&ast.Identifier{Name: "a"}, &ast.Identifier{Name: "b"}}, |
| 42 | From: []ast.TableReference{{Name: "users"}}, |
| 43 | Where: &ast.BinaryExpression{ |
| 44 | Left: &ast.Identifier{Name: "active"}, |
| 45 | Operator: "=", |
| 46 | Right: &ast.LiteralValue{Value: "true"}, |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | result := fmtStmt(stmt, ast.CompactStyle()) |
| 51 | if strings.Contains(result, "\n") { |
| 52 | t.Errorf("CompactStyle should be single line, got: %s", result) |
| 53 | } |
| 54 | if !strings.Contains(result, "SELECT") { |
| 55 | t.Errorf("should contain SELECT, got: %s", result) |
| 56 | } |
| 57 | if !strings.Contains(result, "FROM users") { |
| 58 | t.Errorf("should contain FROM users, got: %s", result) |
| 59 | } |
| 60 | if !strings.Contains(result, "WHERE") { |
| 61 | t.Errorf("should contain WHERE, got: %s", result) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestRenderSelect_Readable(t *testing.T) { |
| 66 | stmt := &ast.SelectStatement{ |
nothing calls this directly
no test coverage detected