forked from Masterminds/squirrel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
row_test.go
34 lines (28 loc) · 626 Bytes
/
row_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package squirrel
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
type RowStub struct {
Scanned bool
}
func (r *RowStub) Scan(_ ...interface{}) error {
r.Scanned = true
return nil
}
func TestRowScan(t *testing.T) {
stub := &RowStub{}
row := &Row{RowScanner: stub}
err := row.Scan()
assert.True(t, stub.Scanned, "row was not scanned")
assert.NoError(t, err)
}
func TestRowScanErr(t *testing.T) {
stub := &RowStub{}
rowErr := fmt.Errorf("scan err")
row := &Row{RowScanner: stub, err: rowErr}
err := row.Scan()
assert.False(t, stub.Scanned, "row was scanned")
assert.Equal(t, rowErr, err)
}