Skip to content

Commit 7c3fd20

Browse files
committed
add url tests
1 parent 4c83f1b commit 7c3fd20

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test:
2+
adapter: sqlite3
3+
database: db/test.sqlite3
4+
pool: 5
5+
timeout: 5000
6+
mongodb_logger:
7+
url: mongodb://localhost:27017/system_log

test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Test::Unit::TestCase
2323
SAMPLE_CONFIG_DIR = File.join(CONFIG_DIR, "samples")
2424
DEFAULT_CONFIG = "database.yml"
2525
DEFAULT_CONFIG_WITH_AUTH = "database_with_auth.yml"
26+
DEFAULT_CONFIG_WITH_URL = "database_with_url.yml"
2627
DEFAULT_CONFIG_WITH_COLLECTION = "database_with_collection.yml"
2728
DEFAULT_CONFIG_WITH_NO_FILE_LOGGING = "database_no_file_logging.yml"
2829
MONGOID_CONFIG = "mongoid.yml"

test/unit/mongodb_logger_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ class MongodbLogger::LoggerTest < Test::Unit::TestCase
4646
teardown_for_config(MONGOID_CONFIG)
4747
end
4848
end
49+
50+
context "upon connecting with url settings" do
51+
setup do
52+
setup_for_config(DEFAULT_CONFIG_WITH_URL, DEFAULT_CONFIG)
53+
end
54+
55+
should "connect with the url" do
56+
@mongodb_logger.send(:connect)
57+
assert @mongodb_logger.authenticated?
58+
assert_equal "system_log", @mongodb_logger.mongo_connection.name
59+
assert_equal ["localhost", 27017], @mongodb_logger.mongo_connection.connection.primary
60+
end
61+
end
4962

5063
# this test will work without the --auth mongod arg
5164
context "upon connecting with authentication settings" do

0 commit comments

Comments
 (0)