From 87d76281eb374f4c4538fe5bf5b774b73dd5d7e3 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 6 Jan 2014 10:24:43 +0100 Subject: first interesting tests --- .travis.yml | 5 ++++ bin/tapicero | 6 ++--- test/integration/tapicero_test.rb | 51 +++++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 2 +- 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ecbf265..163f92b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,10 @@ notifications: email: false before_script: - "/bin/bash test/setup_couch.sh" + - "touch /tmp/test-tapicero.log" - "bundle exec bin/tapicero start test/config.yaml" + - "bundle exec bin/tapicero status" - "cat /tmp/test-tapicero.log" +after_script: + - "cat /tmp/test-tapicero.log" + - "cat /tmp/test-tapicero.seq" diff --git a/bin/tapicero b/bin/tapicero index f72b0db..32cc228 100755 --- a/bin/tapicero +++ b/bin/tapicero @@ -59,7 +59,6 @@ end # # Start the daemon # -require 'tapicero' # so we can use Tapicero.logger below. require 'daemons' if ENV["USER"] == "root" options = {:app_name => 'tapicero', :dir_mode => :system} # this will put the pid file in /var/run @@ -70,7 +69,6 @@ begin Daemons.run("#{BASE_DIR}/lib/tapicero_daemon.rb", options) rescue SystemExit rescue Exception => exc - Tapicero.logger.error "Uncaught exception. Daemon will die." - Tapicero.logger.error exc.class.name + ": " + exc.to_s - Tapicero.logger.error exc.backtrace.join("\n") + puts exc.class.name + exc.to_s + puts exc.backtrace.join("\n") end diff --git a/test/integration/tapicero_test.rb b/test/integration/tapicero_test.rb index b83263a..d436e6d 100644 --- a/test/integration/tapicero_test.rb +++ b/test/integration/tapicero_test.rb @@ -1,4 +1,55 @@ require File.expand_path('../../test_helper.rb', __FILE__) class TapiceroTest < MiniTest::Unit::TestCase + + def test_loads_config + assert_equal "tapicero-test", config.connection[:prefix] + assert_equal "debug", config.send(:log_level) + end + + def test_database_exists + assert database + end + + def test_creates_user_db_fast + user_id = create_user['id'] + database.save_doc :id => user_id + assert user_database(user_id) + end + + def test_creates_user_db_slow + user_id = create_user['id'] + sleep 1 + assert user_database(user_id) + end + + def test_configures_security + user_id = create_user['id'] + sleep 1 + assert_equal config.options[:security], user_database(user_id).get(_security) + end + + def create_user + database.save_doc :some => :content + end + + def user_database(name) + host.database(config.options[:db_prefix] + name) + end + + def database + @database ||= host.database(database_name) + end + + def database_name + config.complete_db_name('users') + end + + def host + @host ||= CouchRest.new(config.couch_host) + end + + def config + Tapicero.config + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3857e2c..227cde5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -6,5 +6,5 @@ $:.unshift File.expand_path('lib', BASE_DIR) require 'mocha/setup' -TAPICERO_CONFIG = "test/config/config.yaml" +TAPICERO_CONFIG = "test/config.yaml" require 'tapicero' -- cgit v1.2.3