diff --git a/testsuite/suite.go b/testsuite/suite.go index aaf65cb..daa6b5e 100644 --- a/testsuite/suite.go +++ b/testsuite/suite.go @@ -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) { diff --git a/testsuite/transaction.go b/testsuite/transaction.go index 8bdf70b..89b895b 100644 --- a/testsuite/transaction.go +++ b/testsuite/transaction.go @@ -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) { @@ -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) + } +}