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

Function TestAssignments

clause/set_test.go:50–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestAssignments(t *testing.T) {
51 set := clause.Assignments(map[string]interface{}{
52 "name": "jinzhu",
53 "age": 18,
54 })
55
56 assignments := []clause.Assignment(set)
57
58 sort.Slice(assignments, func(i, j int) bool {
59 return strings.Compare(assignments[i].Column.Name, assignments[j].Column.Name) > 0
60 })
61
62 if len(assignments) != 2 || assignments[0].Column.Name != "name" || assignments[0].Value.(string) != "jinzhu" || assignments[1].Column.Name != "age" || assignments[1].Value.(int) != 18 {
63 t.Errorf("invalid assignments, got %v", assignments)
64 }
65}

Callers

nothing calls this directly

Calls 1

AssignmentsFunction · 0.92

Tested by

no test coverage detected