Skip to content

Commit

Permalink
tx+boom+ID specification -> panic!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
sinmetal committed Dec 5, 2017
1 parent 28a60d7 commit 67794fa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions testsuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var TestSuite = map[string]Test{
"TransactionBatch_PutAndAllocateIDs": TransactionBatch_PutAndAllocateIDs,
"TransactionBatch_Get": TransactionBatch_Get,
"TransactionBatch_Delete": TransactionBatch_Delete,
"Transaction_WithBoom": Transaction_WithBoom,
}

func MergeTestSuite(suite map[string]Test) {
Expand Down
32 changes: 32 additions & 0 deletions testsuite/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"go.mercari.io/datastore"
"go.mercari.io/datastore/boom"
)

func Transaction_Commit(t *testing.T, ctx context.Context, client datastore.Client) {
Expand Down Expand Up @@ -273,3 +274,34 @@ func RunInTransaction_Rollback(t *testing.T, ctx context.Context, client datasto
t.Fatal(err)
}
}

func Transaction_WithBoom(t *testing.T, ctx context.Context, client datastore.Client) {
defer func() {
err := client.Close()
if err != nil {
t.Fatal(err)
}
}()

bm := boom.FromClient(ctx, client)

type Data struct {
ID string `boom:"id" datastore:"-"`
}

tx, err := bm.NewTransaction()
if err != nil {
t.Fatal(err)
}

_, err = tx.PutMulti([]*Data{&Data{
ID: "hoge",
}})
if err != nil {
t.Fatal(err)
}
_, err = tx.Commit()
if err != nil {
t.Fatal(err)
}
}

0 comments on commit 67794fa

Please sign in to comment.