Commit 946fca89 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 29ffb326
......@@ -145,12 +145,16 @@ type Transaction interface {
//
// Commit completes the transaction by executing the two-phase commit
// algorithm for all DataManagers associated with the transaction.
//
// Commit must not be called after transaction completion began.
Commit(ctx context.Context) error
// Abort aborts the transaction.
//
// Abort completes the transaction by executing Abort on all
// DataManagers associated with it.
//
// Abort must not be called after transaction completion began.
Abort() // XXX + ctx, error?
// XXX + Doom?
......
......@@ -27,7 +27,7 @@ func TestBasic(t *testing.T) {
defer func() {
r := recover()
if r == nil {
t.Fatal("Current(ø) -> not paniced")
t.Fatal("Current(ø) -> no panic")
}
if want := "transaction: no current transaction"; r != want {
......@@ -50,7 +50,7 @@ func TestBasic(t *testing.T) {
defer func() {
r := recover()
if r == nil {
t.Fatal("New(!ø) -> not paniced")
t.Fatal("New(!ø) -> no panic")
}
if want := "transaction: new: nested transactions not supported"; r != want {
......@@ -99,5 +99,18 @@ func TestAbort(t *testing.T) {
t.Fatalf("abort: nabort=%d; txn.Status=%v", dm.nabort, txn.Status())
}
// txn.Abort() -> panic XXX
// Abort 2nd time -> panic
func() {
defer func() {
r := recover()
if r == nil {
t.Fatal("Abort2 -> no panic")
}
if want := "transaction: abort: transaction completion already began"; r != want {
t.Fatalf("Abort2 -> %q; want %q", r, want)
}
}()
txn.Abort()
}()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment