─── INSERT ──────────────────────────────────────────────────────────────────
(t *testing.T)
| 164 | // ─── INSERT ────────────────────────────────────────────────────────────────── |
| 165 | |
| 166 | func TestRenderInsert_Readable(t *testing.T) { |
| 167 | stmt := &ast.InsertStatement{ |
| 168 | TableName: "users", |
| 169 | Columns: []ast.Expression{&ast.Identifier{Name: "name"}, &ast.Identifier{Name: "age"}}, |
| 170 | Values: [][]ast.Expression{ |
| 171 | {&ast.LiteralValue{Value: "'Alice'"}, &ast.LiteralValue{Value: "30"}}, |
| 172 | }, |
| 173 | } |
| 174 | |
| 175 | result := fmtStmt(stmt, ast.ReadableStyle()) |
| 176 | if !strings.Contains(result, "INSERT INTO") { |
| 177 | t.Errorf("should contain INSERT INTO, got: %s", result) |
| 178 | } |
| 179 | if !strings.Contains(result, "VALUES") { |
| 180 | t.Errorf("should contain VALUES, got: %s", result) |
| 181 | } |
| 182 | if !strings.HasSuffix(strings.TrimSpace(result), ";") { |
| 183 | t.Errorf("should end with semicolon, got: %s", result) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | func TestRenderInsert_WithQuery(t *testing.T) { |
| 188 | stmt := &ast.InsertStatement{ |
nothing calls this directly
no test coverage detected