forked from go/pgm
Audit with AI
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package playground
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.patial.tech/go/pgm/playground/db"
|
||||
@@ -26,6 +28,21 @@ func TestUpdateQuery(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateQueryValidation(t *testing.T) {
|
||||
// Test that UPDATE without Set() returns error
|
||||
err := db.User.Update().
|
||||
Where(user.Email.Eq("aa@aa.com")).
|
||||
Exec(context.Background())
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error when calling Exec() without Set(), got nil")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "no columns to update") {
|
||||
t.Errorf("Expected error message to contain 'no columns to update', got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkUpdateQuery-12 2004985 592.2 ns/op 1176 B/op 20 allocs/op
|
||||
func BenchmarkUpdateQuery(b *testing.B) {
|
||||
for b.Loop() {
|
||||
|
||||
Reference in New Issue
Block a user