─── UPDATE ──────────────────────────────────────────────────────────────────
(t *testing.T)
| 227 | // ─── UPDATE ────────────────────────────────────────────────────────────────── |
| 228 | |
| 229 | func TestRenderUpdate_Readable(t *testing.T) { |
| 230 | stmt := &ast.UpdateStatement{ |
| 231 | TableName: "users", |
| 232 | Assignments: []ast.UpdateExpression{ |
| 233 | {Column: &ast.Identifier{Name: "name"}, Value: &ast.LiteralValue{Value: "'Bob'"}}, |
| 234 | }, |
| 235 | Where: &ast.BinaryExpression{Left: &ast.Identifier{Name: "id"}, Operator: "=", Right: &ast.LiteralValue{Value: "1"}}, |
| 236 | } |
| 237 | |
| 238 | result := fmtStmt(stmt, ast.ReadableStyle()) |
| 239 | if !strings.Contains(result, "UPDATE") { |
| 240 | t.Errorf("should contain UPDATE, got: %s", result) |
| 241 | } |
| 242 | if !strings.Contains(result, "SET") { |
| 243 | t.Errorf("should contain SET, got: %s", result) |
| 244 | } |
| 245 | if !strings.Contains(result, "WHERE") { |
| 246 | t.Errorf("should contain WHERE, got: %s", result) |
| 247 | } |
| 248 | lines := strings.Split(result, "\n") |
| 249 | if len(lines) < 3 { |
| 250 | t.Errorf("should have multiple lines, got: %s", result) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func TestRenderUpdate_AllClauses(t *testing.T) { |
| 255 | stmt := &ast.UpdateStatement{ |
nothing calls this directly
no test coverage detected