Skip to content

Commit

Permalink
Add tests for issue32
Browse files Browse the repository at this point in the history
  • Loading branch information
tenntenn committed Sep 11, 2020
1 parent 739ffe3 commit 83eeec5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions passes/unclosetx/testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"cloud.google.com/go/spanner"
"golang.org/x/sync/errgroup"
)

func f1(ctx context.Context, client *spanner.Client) {
Expand Down Expand Up @@ -54,3 +55,21 @@ func f5(ctx context.Context, client *spanner.Client) {
tx, _ := client.BatchReadOnlyTransaction(ctx, spanner.StrongRead()) // want "transaction must be closed"
_ = tx
}

// see https://github.com/gcpug/zagane/issues/32
func f6(ctx context.Context, client *spanner.Client) error {
tx := client.ReadOnlyTransaction() // OK
defer tx.Close()

var eg errgroup.Group

eg.Go(func() error {
_ = tx // use tx
return nil
})

if err := eg.Wait(); err != nil {
return err
}
return nil
}

0 comments on commit 83eeec5

Please sign in to comment.