MCPcopy Index your code
hub / github.com/coder/coder / compareFns

Function compareFns

coderd/database/gentest/modelqueries_test.go:90–107  ·  view source on GitHub ↗
(t *testing.T, aName, bName string, a, b *parsedFunc)

Source from the content-addressed store, hash-verified

88}
89
90func compareFns(t *testing.T, aName, bName string, a, b *parsedFunc) bool {
91 if a == nil {
92 t.Errorf("The function %q is missing", aName)
93 return false
94 }
95 if b == nil {
96 t.Errorf("The function %q is missing", bName)
97 return false
98 }
99 r := compareArgs(t, "rows.Scan() arguments", aName, bName, a.RowScanArgs, b.RowScanArgs)
100 if len(a.QueryArgs) > 2 && len(b.QueryArgs) > 2 {
101 // This is because the actual query param name is different. One uses the
102 // const, the other uses a variable that is a mutation of the original query.
103 a.QueryArgs[1] = b.QueryArgs[1]
104 }
105 q := compareArgs(t, "db.QueryContext() arguments", aName, bName, a.QueryArgs, b.QueryArgs)
106 return r && q
107}
108
109func compareArgs(t *testing.T, argType string, aName, bName string, a, b []ast.Expr) bool {
110 return assert.Equal(t, argList(t, a), argList(t, b), "mismatched %s for %s and %s", argType, aName, bName)

Callers 1

Calls 2

compareArgsFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected