Skip to content

Commit

Permalink
PR FIXUP - TransactionID not TransactionId
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Feb 15, 2023
1 parent 2ea5f10 commit 274b694
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tests/integration/mutation/simple/mix/with_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestMutationWithTxnDoesNotAllowUpdateInSecondTransactionUser(t *testing.T)
}`,
},
testUtils.TransactionRequest2{
TransactionId: 0,
TransactionID: 0,
Request: `mutation {
update_user(data: "{\"age\": 28}") {
_key
Expand All @@ -242,7 +242,7 @@ func TestMutationWithTxnDoesNotAllowUpdateInSecondTransactionUser(t *testing.T)
},
},
testUtils.TransactionRequest2{
TransactionId: 1,
TransactionID: 1,
Request: `mutation {
update_user(data: "{\"age\": 29}") {
_key
Expand All @@ -259,10 +259,10 @@ func TestMutationWithTxnDoesNotAllowUpdateInSecondTransactionUser(t *testing.T)
},
},
testUtils.TransactionCommit{
TransactionId: 0,
TransactionID: 0,
},
testUtils.TransactionCommit{
TransactionId: 1,
TransactionID: 1,
ExpectedError: "Transaction Conflict. Please retry",
},
testUtils.Request{
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type Request struct {
// provided.
type TransactionRequest2 struct {
// Used to identify the transaction for this to run against.
TransactionId int
TransactionID int

// The request to run against the transaction.
Request string
Expand All @@ -120,7 +120,7 @@ type TransactionRequest2 struct {
// TransactionCommit represents a commit request for a transaction of the given id.
type TransactionCommit struct {
// Used to identify the transaction to commit.
TransactionId int
TransactionID int

// Any error expected from the action. Optional.
//
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,23 +545,23 @@ func executeTransactionRequest(
testCase TestCase,
action TransactionRequest2,
) []datastore.Txn {
if action.TransactionId >= len(txns) {
if action.TransactionID >= len(txns) {
// Extend the txn slice so this txn can fit and be accessed by TransactionId
txns = append(txns, make([]datastore.Txn, action.TransactionId-len(txns)+1)...)
txns = append(txns, make([]datastore.Txn, action.TransactionID-len(txns)+1)...)
}

if txns[action.TransactionId] == nil {
if txns[action.TransactionID] == nil {
// Create a new transaction if one does not already exist.
txn, err := db.NewTxn(ctx, false)
if AssertError(t, testCase.Description, err, action.ExpectedError) {
txn.Discard(ctx)
return nil
}

txns[action.TransactionId] = txn
txns[action.TransactionID] = txn
}

result := db.ExecTransactionalRequest(ctx, action.Request, txns[action.TransactionId])
result := db.ExecTransactionalRequest(ctx, action.Request, txns[action.TransactionID])
expectedErrorRaised := assertRequestResults(
ctx,
t,
Expand All @@ -576,7 +576,7 @@ func executeTransactionRequest(
if expectedErrorRaised {
// Make sure to discard the transaction before exit, else an unwanted error
// may surface later (e.g. on database close).
txns[action.TransactionId].Discard(ctx)
txns[action.TransactionID].Discard(ctx)
return nil
}

Expand All @@ -594,9 +594,9 @@ func commitTransaction(
testCase TestCase,
action TransactionCommit,
) {
err := txns[action.TransactionId].Commit(ctx)
err := txns[action.TransactionID].Commit(ctx)
if err != nil {
txns[action.TransactionId].Discard(ctx)
txns[action.TransactionID].Discard(ctx)
}

expectedErrorRaised := AssertError(t, testCase.Description, err, action.ExpectedError)
Expand Down

0 comments on commit 274b694

Please sign in to comment.