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
97ffc613
Commit
97ffc613
authored
Jul 24, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
02dad3fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
go/transaction/transaction.go
go/transaction/transaction.go
+1
-1
go/transaction/transaction_test.go
go/transaction/transaction_test.go
+47
-0
No files found.
go/transaction/transaction.go
View file @
97ffc613
...
...
@@ -56,7 +56,7 @@ func currentTxn(ctx context.Context) Transaction {
// newTxn serves New.
func
newTxn
(
ctx
context
.
Context
)
(
Transaction
,
context
.
Context
)
{
if
getTxn
(
ctx
)
!=
nil
{
panic
(
"transaction: ne
sted transactions are
not supported"
)
panic
(
"transaction: ne
w: nested transactions
not supported"
)
}
txn
:=
&
transaction
{
status
:
Active
}
...
...
go/transaction/transaction_test.go
View file @
97ffc613
...
...
@@ -12,3 +12,50 @@
// FOR A PARTICULAR PURPOSE.
package
transaction
import
(
"context"
"testing"
)
func
TestBasic
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
// Current(ø) -> panic
func
()
{
defer
func
()
{
r
:=
recover
()
if
r
==
nil
{
t
.
Fatal
(
"Current(ø) -> not paniced"
)
}
if
want
:=
"transaction: no current transaction"
;
r
!=
want
{
t
.
Fatalf
(
"Current(ø) -> %q; want %q"
,
r
,
want
)
}
}()
Current
(
ctx
)
}()
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
func
()
{
defer
func
()
{
r
:=
recover
()
if
r
==
nil
{
t
.
Fatal
(
"New(!ø) -> not paniced"
)
}
if
want
:=
"transaction: new: nested transactions not supported"
;
r
!=
want
{
t
.
Fatalf
(
"New(!ø) -> %q; want %q"
,
r
,
want
)
}
}()
_
,
_
=
New
(
ctx
)
}()
}
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