forked from Masterminds/squirrel
-
Notifications
You must be signed in to change notification settings - Fork 38
/
result_test.go
40 lines (30 loc) · 861 Bytes
/
result_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
35
36
37
38
39
40
package sqrl
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRowsAffected(t *testing.T) {
testErr := errors.New("test error")
c, err := RowsAffected(nil, testErr)
assert.Zero(t, c)
assert.Equal(t, testErr, err)
c, err = RowsAffected(&resultStub{err: testErr}, nil)
assert.Zero(t, c)
assert.Equal(t, testErr, err)
c, err = RowsAffected(&resultStub{rowsAffected: 42}, nil)
assert.Equal(t, int64(42), c)
assert.NoError(t, err)
}
func TestLastInsertId(t *testing.T) {
testErr := errors.New("test error")
c, err := LastInsertId(nil, testErr)
assert.Zero(t, c)
assert.Equal(t, testErr, err)
c, err = LastInsertId(&resultStub{err: testErr}, nil)
assert.Zero(t, c)
assert.Equal(t, testErr, err)
c, err = LastInsertId(&resultStub{lastInsertId: 42}, nil)
assert.Equal(t, int64(42), c)
assert.NoError(t, err)
}