-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to LogDevice. New LogDevice tests. Testing reorg.
- Loading branch information
Jim Menard
committed
Jan 22, 2009
1 parent
0eca85d
commit 45c71cf
Showing
4 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'test_helper' | ||
|
||
class LoggerTest < ActiveSupport::TestCase | ||
|
||
MAX_RECS = 3 | ||
|
||
def setup | ||
$db.collection('testlogger').drop() | ||
# Create a log device with a max of MAX_RECS records | ||
@logger = Logger.new(MongoRecord::LogDevice.new('testlogger', :size => 1_000_000, :max => MAX_RECS)) | ||
@log_collection = $db.collection('testlogger') | ||
end | ||
|
||
def teardown | ||
$db.collection('testlogger').drop() | ||
end | ||
|
||
# We really don't have to test much more than this. We can trust that Mongo | ||
# works properly. | ||
test "max records enforced" do | ||
assert_equal $db.name, MongoRecord::LogDevice.connection.name | ||
MAX_RECS.times { |i| | ||
@logger.debug("test message #{i+1}") | ||
assert_equal i+1, @log_collection.count() | ||
} | ||
|
||
MAX_RECS.times { |i| | ||
@logger.debug("test message #{i+MAX_RECS+1}") | ||
assert_equal MAX_RECS, @log_collection.count() | ||
} | ||
end | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
require 'test_helper' | ||
require 'mongo' | ||
|
||
class MongoRecordTest < ActiveSupport::TestCase | ||
|
||
def setup | ||
@mongo = XGen::Mongo::Driver::Mongo.new | ||
test "can connect to database" do | ||
assert_not_nil $db | ||
list = $db.collection_names | ||
assert_not_nil list | ||
assert_kind_of Array, list | ||
end | ||
|
||
test "can see database names" do | ||
list = @mongo.database_names | ||
list = $mongo.database_names | ||
assert_not_nil list | ||
assert list.size > 0 | ||
assert list.include?('admin') | ||
end | ||
|
||
test "can connect to database" do | ||
db = @mongo.db('mongo_record_test') | ||
assert_not_nil db | ||
list = db.collection_names | ||
assert_not_nil list | ||
assert_kind_of Array, list | ||
end | ||
end |
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