Skip to content

Commit dfa052f

Browse files
committed
TEST/MINOR: transactions: fix flaky transaction tests
1 parent 0c0c4ef commit dfa052f

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

e2e/tests/transactions/commit.bats

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,19 @@ load '../../libs/version'
2424
load 'utils/_helpers'
2525

2626
@test "transactions: Outdated transactions cannot be committed" {
27-
# creating 5 transactions
28-
for _ in {1..5}; do
29-
resource_post "$_TRANSACTIONS_BASE_PATH" ""
30-
assert_equal "$SC" 201
31-
done
27+
resource_post "$_TRANSACTIONS_BASE_PATH" ""
28+
assert_equal "$SC" 201
29+
local first_id; first_id=$(get_json_path "${BODY}" ".id")
3230

33-
# retrieving the first one
34-
resource_get "$_TRANSACTIONS_BASE_PATH"
35-
local id; id=$(get_json_path "${BODY}" ".[0].id")
31+
resource_post "$_TRANSACTIONS_BASE_PATH" ""
32+
assert_equal "$SC" 201
33+
local second_id; second_id=$(get_json_path "${BODY}" ".id")
3634

37-
# commit it, must succeed
38-
resource_put "$_TRANSACTIONS_BASE_PATH/$id" ""
35+
# commit first one, must succeed
36+
resource_put "$_TRANSACTIONS_BASE_PATH/$first_id" ""
3937
assert_equal "$SC" 202
4038

41-
# retrieve other transactions
42-
resource_get "$_TRANSACTIONS_BASE_PATH"
43-
assert_equal "$SC" 200
44-
# iterate over them, should fail with 406 status code
45-
for tx in $(echo "${BODY}" | jq -r '.[].id'); do
46-
resource_put "$_TRANSACTIONS_BASE_PATH/${tx}" ""
47-
assert_equal "$SC" 406
48-
done
39+
# try to commit second one, must be outdated
40+
resource_put "$_TRANSACTIONS_BASE_PATH/$second_id" ""
41+
assert_equal "$SC" 406
4942
}

0 commit comments

Comments
 (0)