Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created May 27, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/a6897879372bb1ef21853d539a142169 to your computer and use it in GitHub Desktop.
Save chelseatroy/a6897879372bb1ef21853d539a142169 to your computer and use it in GitHub Desktop.
Commission Tests
require_relative "database"
require "test/unit"
class TestDatabase < Test::Unit::TestCase
...
def test_commit_with_transaction
db = Database.new
db.set "BlueAndGold", "Maccaw"
assert_equal(1, db.count("Maccaw"))
db.begin
db.set "GreenWing", "Maccaw"
db.commit
assert_equal(2, db.count("Maccaw"))
assert_equal("Maccaw", db.get("GreenWing"))
end
def test_commit_no_transaction
db = Database.new
assert_equal("No transaction in progress", db.commit)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment