Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test Nested Transactions
...
def test_nested_transaction
db = Database.new
db.set "Pacific", "Baza"
assert_equal(1, db.count("Baza"))
db.begin
db.set "Black", "Baza"
assert_equal(2, db.count("Baza"))
assert_equal("Baza", db.get("Black"))
db.begin
db.set "Jerdons", "Baza"
assert_equal(3, db.count("Baza"))
assert_equal("Baza", db.get("Jerdons"))
db.rollback
assert_equal(2, db.count("Baza"))
assert_equal("Baza", db.get("Black"))
assert_equal("Baza", db.get("Pacific"))
db.commit
assert_equal(2, db.count("Baza"))
assert_equal("Baza", db.get("Pacific"))
assert_equal("Baza", db.get("Black"))
assert_equal("NULL", db.get("Jerdons"))
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment