Created
May 27, 2019 21:39
-
-
Save chelseatroy/0ab3eab13d721381d43a2ba698884e7d to your computer and use it in GitHub Desktop.
Test Nested Transactions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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