Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
viewsharp committed Oct 19, 2024
1 parent 8e385b4 commit 92e8e91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/booktest/mysql/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func TestBooks(t *testing.T) {
Title: "my book title",
Yr: 2016,
})
for book := range rows.Iterate() {

// We need to collect the iterator elements to avoid panic when we make other db queries in the loop.
for _, book := range slices.Collect(rows.Iterate()) {
t.Logf("Book %d (%s): %s available: %s\n", book.BookID, book.BookType, book.Title, book.Available.Format(time.RFC822Z))
author, err := dq.GetAuthor(ctx, book.AuthorID)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion examples/booktest/postgresql/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ func TestBooks(t *testing.T) {
Title: "my book title",
Year: 2016,
})
for book := range rows.Iterate() {

// We need to collect the iterator elements to avoid panic when we make other db queries in the loop.
for _, book := range slices.Collect(rows.Iterate()) {
t.Logf("Book %d (%s): %s available: %s\n", book.BookID, book.BookType, book.Title, book.Available.Time.Format(time.RFC822Z))
author, err := dq.GetAuthor(ctx, book.AuthorID)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion examples/booktest/sqlite/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ func TestBooks(t *testing.T) {
Title: "my book title",
Yr: 2016,
})
for book := range rows.Iterate() {

// We need to collect the iterator elements to avoid panic when we make other db queries in the loop.
for _, book := range slices.Collect(rows.Iterate()) {
t.Logf("Book %d (%s): %s available: %s\n", book.BookID, book.BookType, book.Title, book.Available.Format(time.RFC822Z))
author, err := dq.GetAuthor(ctx, book.AuthorID)
if err != nil {
Expand Down

0 comments on commit 92e8e91

Please sign in to comment.