aboutsummaryrefslogtreecommitdiff
path: root/internal/mock/driver.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-04-14 00:41:25 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-04-14 00:41:25 +0200
commit9191e018ff90deb99f3881966a5d356a05027e0f (patch)
treec36880ed2c0755132306141e61c8073d2926b0de /internal/mock/driver.go
parent49a52b73afac2c97a8f3b7cffd434b29e6f30fcf (diff)
downloadgo-oblast-9191e018ff90deb99f3881966a5d356a05027e0f.tar.gz
initial test coverage for Store.Select functions
Diffstat (limited to 'internal/mock/driver.go')
-rw-r--r--internal/mock/driver.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/internal/mock/driver.go b/internal/mock/driver.go
index 4183097..d3358c4 100644
--- a/internal/mock/driver.go
+++ b/internal/mock/driver.go
@@ -75,22 +75,26 @@ func newExpectation[T any](args []any) expectation[T] {
output: new(T),
}
for idx, arg := range args {
- e.args[idx] = arg
+ var err error
+ e.args[idx], err = driver.DefaultParameterConverter.ConvertValue(arg)
+ if err != nil {
+ panic(fmt.Sprintf("could not convert value %#v into driver.Value: %s", arg, err.Error()))
+ }
}
return e
}
-// ExpectExec plans a response to an Exec() call.
-func (rs *ResponseSet) ExpectExec(args ...any) *Result {
+// ExpectExecWithArgs plans a response to an Exec() call.
+func (rs *ResponseSet) ExpectExecWithArgs(args ...any) *Result {
e := newExpectation[Result](args)
rs.expectedExecs = append(rs.expectedExecs, e)
return e.output
}
-// ExpectQuery plans a response to a Query() or QueryRows() call.
-func (rs *ResponseSet) ExpectQuery(args ...any) *Result {
- e := newExpectation[Result](args)
- rs.expectedExecs = append(rs.expectedExecs, e)
+// ExpectQueryWithArgs plans a response to a Query() or QueryRows() call.
+func (rs *ResponseSet) ExpectQueryWithArgs(args ...any) *Rows {
+ e := newExpectation[Rows](args)
+ rs.expectedQueries = append(rs.expectedQueries, e)
return e.output
}
@@ -258,7 +262,7 @@ func (r *Rows) AndReturnColumns(columns ...string) *Rows {
// WithRow adds a row to the result set that will be returned by this query.
// This may only be called after AndReturnColumns().
func (r *Rows) WithRow(values ...any) *Rows {
- if len(r.columns) != 0 {
+ if len(r.columns) == 0 {
panic("AndReturnColumns() has not been called for this Rows object yet")
}
if len(r.columns) != len(values) {