Kouhei Sutou
null+****@clear*****
Wed Feb 3 15:58:13 JST 2016
Kouhei Sutou 2016-02-03 15:58:13 +0900 (Wed, 03 Feb 2016) New Revision: 3e4827d92652010057092673210c708e9a4cb622 https://github.com/groonga/groonga/commit/3e4827d92652010057092673210c708e9a4cb622 Message: test grndb: add tests for nonexistent table case Modified files: test/command_line/helper.rb test/command_line/suite/grndb/test_check.rb Modified: test/command_line/helper.rb (+1 -0) =================================================================== --- test/command_line/helper.rb 2016-02-03 15:57:50 +0900 (569fea9) +++ test/command_line/helper.rb 2016-02-03 15:58:13 +0900 (3dd78dc) @@ -1,4 +1,5 @@ require "fileutils" +require "json" require "test-unit" Modified: test/command_line/suite/grndb/test_check.rb (+43 -0) =================================================================== --- test/command_line/suite/grndb/test_check.rb 2016-02-03 15:57:50 +0900 (878c326) +++ test/command_line/suite/grndb/test_check.rb 2016-02-03 15:58:13 +0900 (cfc2926) @@ -12,6 +12,18 @@ Database is locked. It may be broken. Re-create the database. MESSAGE end + def test_nonexistent_table + groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") + _id, _name, path, *_ = JSON.parse(groonga("table_list").output)[1][1] + FileUtils.rm(path) + error = assert_raise(CommandRunner::Error) do + grndb("check") + end + assert_equal(<<-MESSAGE, error.error_output) +[Users] Can't open object. It's broken. Re-create the object or the database. + MESSAGE + end + def test_locked_table groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") groonga("lock_acquire", "Users") @@ -53,6 +65,18 @@ Database is locked. It may be broken. Re-create the database. end sub_test_case "--target" do + def test_nonexistent_table + groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") + _id, _name, path, *_ = JSON.parse(groonga("table_list").output)[1][1] + FileUtils.rm(path) + error = assert_raise(CommandRunner::Error) do + grndb("check", "--target", "Users") + end + assert_equal(<<-MESSAGE, error.error_output) +[Users] Can't open object. It's broken. Re-create the object or the database. + MESSAGE + end + def test_locked_table groonga("table_create", "Bookmarks", "TABLE_HASH_KEY", "ShortText") groonga("column_create", "Bookmarks", "title", @@ -90,6 +114,25 @@ Database is locked. It may be broken. Re-create the database. MESSAGE end + def test_nonexistent_referenced_table + groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") + groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8") + + groonga("table_create", "Bookmarks", "TABLE_HASH_KEY", "ShortText") + groonga("column_create", "Bookmarks", "user", "COLUMN_SCALAR", "Users") + + JSON.parse(groonga("table_list").output)[1].each do |table| + _id, name, path, *_ = table + FileUtils.rm(path) if name == "Users" + end + error = assert_raise(CommandRunner::Error) do + grndb("check", "--target", "Bookmarks") + end + assert_equal(<<-MESSAGE, error.error_output) +[Users] Can't open object. It's broken. Re-create the object or the database. + MESSAGE + end + def test_referenced_table_by_table groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8") -------------- next part -------------- HTML����������������������������... Descargar