Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
7cb2f43d
Commit
7cb2f43d
authored
Jul 24, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
97ffc613
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
go/transaction/transaction_test.go
go/transaction/transaction_test.go
+34
-1
No files found.
go/transaction/transaction_test.go
View file @
7cb2f43d
...
...
@@ -15,6 +15,7 @@ package transaction
import
(
"context"
"sync/atomic"
"testing"
)
...
...
@@ -38,12 +39,13 @@ func TestBasic(t *testing.T) {
}()
// New
txn
,
ctx
:=
New
(
ctx
)
if
txn_
:=
Current
(
ctx
);
txn_
!=
txn
{
t
.
Fatalf
(
"New inconsistent with Current: txn = %#v; txn_ = %#v"
,
txn
,
txn_
)
}
//
subtransactions not allowed
//
New(!ø) -> panic
func
()
{
defer
func
()
{
r
:=
recover
()
...
...
@@ -59,3 +61,34 @@ func TestBasic(t *testing.T) {
_
,
_
=
New
(
ctx
)
}()
}
// DataManager that verifies abort path.
type
dmAbortOnly
struct
{
t
*
testing
.
T
txn
Transaction
nabort
int32
}
func
(
d
*
dmAbortOnly
)
Abort
(
txn
Transaction
)
{
if
txn
!=
d
.
txn
{
d
.
t
.
Fatalf
(
"abort: txn is different"
)
}
atomic
.
AddInt32
(
&
d
.
nabort
,
+
1
)
}
func
(
d
*
dmAbortOnly
)
bug
()
{
d
.
t
.
Fatal
(
"must not be called on abort"
)
}
func
(
d
*
dmAbortOnly
)
TPCBegin
(
_
Transaction
)
{
d
.
bug
();
panic
(
0
)
}
func
(
d
*
dmAbortOnly
)
Commit
(
_
context
.
Context
,
_
Transaction
)
error
{
d
.
bug
();
panic
(
0
)
}
func
(
d
*
dmAbortOnly
)
TPCVote
(
_
context
.
Context
,
_
Transaction
)
error
{
d
.
bug
();
panic
(
0
)
}
func
(
d
*
dmAbortOnly
)
TPCFinish
(
_
context
.
Context
,
_
Transaction
)
error
{
d
.
bug
();
panic
(
0
)
}
func
(
d
*
dmAbortOnly
)
TPCAbort
(
_
context
.
Context
,
_
Transaction
)
error
{
d
.
bug
();
panic
(
0
)
}
func
TestAbort
(
t
*
testing
.
T
)
{
txn
,
_
:=
New
(
context
.
Background
())
dm
:=
&
dmAbortOnly
{
t
:
t
,
txn
:
txn
}
txn
.
Abort
()
if
dm
.
nabort
!=
1
{
t
.
Fatalf
(
"abort: nabort=%d; want=1"
,
dm
.
nabort
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment