Skip to content

Commit

Permalink
updated query tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Dec 5, 2022
1 parent f2319b9 commit cecf5a8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func TestQuery_Execute(t *testing.T) {
}

type Customer struct {
scanned bool

ID int
Email string
Status int
Expand All @@ -55,6 +57,11 @@ func (m Customer) TableName() string {
return "customer"
}

func (m *Customer) PostScan() error {
m.scanned = true
return nil
}

type CustomerPtr struct {
ID *int `db:"pk"`
Email *string
Expand Down Expand Up @@ -119,6 +126,9 @@ func TestQuery_Rows(t *testing.T) {
assert.Equal(t, customers[2].ID, 3, "customers[2].ID")
assert.Equal(t, customers[2].Email, `[email protected]`, "customers[2].Email")
assert.Equal(t, customers[2].Status, 2, "customers[2].Status")
assert.Equal(t, customers[0].scanned, true, "customers[0].scanned")
assert.Equal(t, customers[1].scanned, true, "customers[1].scanned")
assert.Equal(t, customers[2].scanned, true, "customers[2].scanned")
}

// Query.All() with slice of pointers
Expand All @@ -130,6 +140,9 @@ func TestQuery_Rows(t *testing.T) {
assert.Equal(t, customersPtrSlice[2].ID, 3, "customersPtrSlice[2].ID")
assert.Equal(t, customersPtrSlice[2].Email, `[email protected]`, "customersPtrSlice[2].Email")
assert.Equal(t, customersPtrSlice[2].Status, 2, "customersPtrSlice[2].Status")
assert.Equal(t, customersPtrSlice[0].scanned, true, "customersPtrSlice[0].scanned")
assert.Equal(t, customersPtrSlice[1].scanned, true, "customersPtrSlice[1].scanned")
assert.Equal(t, customersPtrSlice[2].scanned, true, "customersPtrSlice[2].scanned")
}

var customers2 []NullStringMap
Expand Down

0 comments on commit cecf5a8

Please sign in to comment.