MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestRenderUpdate_Readable

Function TestRenderUpdate_Readable

pkg/formatter/render_test.go:229–252  ·  view source on GitHub ↗

─── UPDATE ──────────────────────────────────────────────────────────────────

(t *testing.T)

Source from the content-addressed store, hash-verified

227// ─── UPDATE ──────────────────────────────────────────────────────────────────
228
229func 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
254func TestRenderUpdate_AllClauses(t *testing.T) {
255 stmt := &ast.UpdateStatement{

Callers

nothing calls this directly

Calls 3

ReadableStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected