Skip to content

Commit

Permalink
Merge pull request #569 from upper/issue-565_context_panic
Browse files Browse the repository at this point in the history
Add a test for issue #565
  • Loading branch information
xiam authored May 19, 2020
2 parents 9e4d0ab + 7d99bff commit 02d4f94
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/testsuite/sql_suite.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package testsuite

import (
"context"
"database/sql"
"fmt"
"log"
Expand All @@ -12,6 +13,7 @@ import (

"github.com/stretchr/testify/suite"
db "upper.io/db.v3"
"upper.io/db.v3/lib/sqlbuilder"
)

type customLogger struct {
Expand Down Expand Up @@ -1925,3 +1927,17 @@ func (s *SQLTestSuite) TestCustomType() {

s.Equal("foo: some name", string(bar.Custom.Val))
}

func (s *SQLTestSuite) TestIssue565() {
sess := s.Session().(sqlbuilder.Database)

ctx, _ := context.WithTimeout(context.Background(), time.Nanosecond)

sess = sess.WithContext(ctx)

var result birthday
err := sess.Collection("birthdays").Find().One(&result)

s.Error(err)
s.Zero(result.Name)
}

0 comments on commit 02d4f94

Please sign in to comment.