Kouhei Sutou
null+****@clear*****
Sun Aug 17 11:59:19 JST 2014
Kouhei Sutou 2014-08-17 11:59:19 +0900 (Sun, 17 Aug 2014) New Revision: 70fc69c94b0102232a2369c9d48ea4f680533b53 https://github.com/ranguba/rroonga/commit/70fc69c94b0102232a2369c9d48ea4f680533b53 Message: test: add test name to database path for easy to debug Modified files: test/groonga-test-utils.rb test/test-context.rb test/test-database.rb Modified: test/groonga-test-utils.rb (+3 -2) =================================================================== --- test/groonga-test-utils.rb 2014-08-17 00:29:53 +0900 (d9b0e0d) +++ test/groonga-test-utils.rb 2014-08-17 11:59:19 +0900 (e49e730) @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2009-2014 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -43,6 +43,8 @@ module GroongaTestUtils setup_context @database = nil + name_for_path = name.gsub(/[\(\)\[\] ]/, "-") + @database_path = @tmp_dir + "#{name_for_path}.db" end def setup_tmp_directory @@ -107,7 +109,6 @@ module GroongaTestUtils end def setup_database - @database_path = @tmp_dir + "database" @database = Groonga::Database.create(:path => @database_path.to_s) end Modified: test/test-context.rb (+6 -9) =================================================================== --- test/test-context.rb 2014-08-17 00:29:53 +0900 (21efec2) +++ test/test-context.rb 2014-08-17 11:59:19 +0900 (4dd1fbd) @@ -30,12 +30,11 @@ class ContextTest < Test::Unit::TestCase end def test_create_database - db_path = @tmp_dir + "db" - assert_not_predicate(db_path, :exist?) + assert_not_predicate(@database_path, :exist?) context = Groonga::Context.new assert_equal(nil, context.database) - database = context.create_database(db_path.to_s) - assert_predicate(db_path, :exist?) + database = context.create_database(@database_path.to_s) + assert_predicate(@database_path, :exist?) assert_not_predicate(database, :closed?) assert_equal(database, context.database) end @@ -50,14 +49,13 @@ class ContextTest < Test::Unit::TestCase end def test_open_database - db_path = @tmp_dir + "db" - database = Groonga::Database.create(:path => db_path.to_s) + database = Groonga::Database.create(:path => @database_path.to_s) database.close assert_predicate(database, :closed?) called = false context = Groonga::Context.new - context.open_database(db_path.to_s) do |_database| + context.open_database(@database_path.to_s) do |_database| database = _database assert_not_predicate(database, :closed?) called = true @@ -201,8 +199,7 @@ COMMANDS private def restore(commands, &block) - restored_db_path = @tmp_dir + "restored.db" - Groonga::Database.create(:path => restored_db_path.to_s) + Groonga::Database.create(:path => @database_path.to_s) context.restore(commands, &block) end Modified: test/test-database.rb (+10 -15) =================================================================== --- test/test-database.rb 2014-08-17 00:29:53 +0900 (216c0b5) +++ test/test-database.rb 2014-08-17 11:59:19 +0900 (4b27648) @@ -19,10 +19,9 @@ class DatabaseTest < Test::Unit::TestCase def test_create assert_nil(Groonga::Context.default.database) - db_path = @tmp_dir + "db" - assert_not_predicate(db_path, :exist?) - database = Groonga::Database.create(:path => db_path.to_s) - assert_predicate(db_path, :exist?) + assert_not_predicate(@database_path, :exist?) + database = Groonga::Database.create(:path => @database_path.to_s) + assert_predicate(@database_path, :exist?) assert_not_predicate(database, :closed?) assert_equal(database, Groonga::Context.default.database) @@ -37,13 +36,12 @@ class DatabaseTest < Test::Unit::TestCase end def test_open - db_path = @tmp_dir + "db" - database = Groonga::Database.create(:path => db_path.to_s) + database = Groonga::Database.create(:path => @database_path.to_s) database.close assert_predicate(database, :closed?) called = false - Groonga::Database.open(db_path.to_s) do |_database| + Groonga::Database.open(@database_path.to_s) do |_database| database = _database assert_not_predicate(database, :closed?) called = true @@ -53,29 +51,26 @@ class DatabaseTest < Test::Unit::TestCase end def test_close - db_path = @tmp_dir + "db" - database = Groonga::Database.create(:path => db_path.to_s) + database = Groonga::Database.create(:path => @database_path.to_s) database.close - database = Groonga::Database.open(db_path.to_s) + database = Groonga::Database.open(@database_path.to_s) assert_not_predicate(database, :closed?) database.close assert_predicate(database, :closed?) end def test_new - db_path = @tmp_dir + "db" assert_raise(Groonga::NoSuchFileOrDirectory) do - Groonga::Database.new(db_path.to_s) + Groonga::Database.new(@database_path.to_s) end - Groonga::Database.create(:path => db_path.to_s) + Groonga::Database.create(:path => @database_path.to_s) assert_not_predicate(Groonga::Database.new(db_path.to_s), :closed?) end def test_each - db_path = @tmp_dir + "db" - database = Groonga::Database.create(:path => db_path.to_s) + database = Groonga::Database.create(:path => @database_path.to_s) default_object_names = database.collect {|object| object.name}.sort assert_send([default_object_names, :include?, "Bool"]) end -------------- next part -------------- HTML����������������������������... Télécharger