MCPcopy
hub / github.com/go-gorm/gorm / TestWhereCloneCorruption

Function TestWhereCloneCorruption

statement_test.go:11–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestWhereCloneCorruption(t *testing.T) {
12 for whereCount := 1; whereCount <= 8; whereCount++ {
13 t.Run(fmt.Sprintf("w=%d", whereCount), func(t *testing.T) {
14 s := new(Statement)
15 for w := 0; w < whereCount; w++ {
16 s = s.clone()
17 s.AddClause(clause.Where{
18 Exprs: s.BuildCondition(fmt.Sprintf("where%d", w)),
19 })
20 }
21
22 s1 := s.clone()
23 s1.AddClause(clause.Where{
24 Exprs: s.BuildCondition("FINAL1"),
25 })
26 s2 := s.clone()
27 s2.AddClause(clause.Where{
28 Exprs: s.BuildCondition("FINAL2"),
29 })
30
31 if reflect.DeepEqual(s1.Clauses["WHERE"], s2.Clauses["WHERE"]) {
32 t.Errorf("Where conditions should be different")
33 }
34 })
35 }
36}
37
38func TestNilCondition(t *testing.T) {
39 s := new(Statement)

Callers

nothing calls this directly

Calls 3

cloneMethod · 0.80
AddClauseMethod · 0.80
BuildConditionMethod · 0.80

Tested by

no test coverage detected