rroonga 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,90 +0,0 @@
1
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License version 2.1 as published by the Free Software Foundation.
6
- #
7
- # This library is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
- # Lesser General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU Lesser General Public
13
- # License along with this library; if not, write to the Free Software
14
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
-
16
- class SchemaViewTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_create_view
22
- assert_nil(context["Entries"])
23
- Groonga::Schema.create_view("Entries") do |view|
24
- end
25
- assert_not_nil(context["Entries"])
26
- end
27
-
28
- def test_create_view_force
29
- Groonga::Schema.create_table("People") do |table|
30
- table.string("name")
31
- end
32
- context["People"].add(:name => "morita")
33
-
34
- Groonga::Schema.create_view("Entries") do |view|
35
- view.add("People")
36
- end
37
- assert_equal(["morita"],
38
- context["Entries"].collect {|entry| entry["name"]})
39
-
40
- Groonga::Schema.create_view("People") do |view|
41
- end
42
- assert_equal(["morita"],
43
- context["Entries"].collect {|entry| entry["name"]})
44
-
45
- Groonga::Schema.create_view("Entries", :force => true) do |view|
46
- end
47
- assert_equal([],
48
- context["Entries"].collect {|entry| entry["name"]})
49
- end
50
-
51
- def test_remove_view
52
- Groonga::View.create(:name => "Entries")
53
- assert_not_nil(context["Entries"])
54
- Groonga::Schema.remove_view("Entries")
55
- assert_nil(context["Entries"])
56
- end
57
-
58
- def test_add
59
- Groonga::Schema.create_table("People") do |table|
60
- table.string("name")
61
- end
62
- context["People"].add(:name => "morita")
63
-
64
- Groonga::Schema.create_table("Dogs") do |table|
65
- table.string("name")
66
- end
67
- context["Dogs"].add(:name => "pochi")
68
-
69
- Groonga::Schema.create_view("Entries") do |view|
70
- view.add("People")
71
- view.add("Dogs")
72
- end
73
- assert_equal(["morita", "pochi"],
74
- context["Entries"].collect {|entry| entry["name"]})
75
- end
76
-
77
- def test_define_lazy
78
- assert_nothing_raised do
79
- Groonga::Schema.define do |schema|
80
- schema.create_table("People") do |table|
81
- table.string("name")
82
- end
83
-
84
- schema.create_view("Entries") do |view|
85
- view.add("People")
86
- end
87
- end
88
- end
89
- end
90
- end
data/test/test-view.rb DELETED
@@ -1,71 +0,0 @@
1
- # Copyright (C) 2010 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License version 2.1 as published by the Free Software Foundation.
6
- #
7
- # This library is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
- # Lesser General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU Lesser General Public
13
- # License along with this library; if not, write to the Free Software
14
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
-
16
- class ViewTest < Test::Unit::TestCase
17
- include GroongaTestUtils
18
-
19
- setup :setup_database
20
-
21
- def test_inspect
22
- path = @tables_dir + "users.groonga"
23
- view = Groonga::View.create(:name => "Users", :path => path.to_s)
24
- assert_equal("#<Groonga::View " +
25
- "id: <#{view.id}>, " +
26
- "name: <Users>, " +
27
- "path: <#{path}>, " +
28
- "domain: (nil), " +
29
- "range: (nil), " +
30
- "flags: <>, " +
31
- "size: <0>>",
32
- view.inspect)
33
- end
34
-
35
- def test_encoding
36
- view = Groonga::View.create
37
- assert_false(view.respond_to?(:encoding))
38
- end
39
-
40
- def test_add_table
41
- users = Groonga::Array.create(:name => "Users")
42
- dogs = Groonga::Array.create(:name => "Dogs")
43
- entries = Groonga::View.create(:name => "Entries")
44
- entries.add_table(users)
45
- entries.add_table(dogs)
46
-
47
- assert_equal(0, entries.size)
48
- users.add
49
- assert_equal(1, entries.size)
50
- dogs.add
51
- assert_equal(2, entries.size)
52
- end
53
-
54
- def test_sort
55
- users = Groonga::Hash.create(:name => "Users", :key_type => "ShortText")
56
- dogs = Groonga::Hash.create(:name => "Dogs", :key_type => "ShortText")
57
- entries = Groonga::View.create(:name => "Entries")
58
- entries.add_table(users)
59
- entries.add_table(dogs)
60
-
61
- users.add("morita")
62
- users.add("tasuku")
63
- users.add("yu")
64
- dogs.add("pochi")
65
- dogs.add("bob")
66
- dogs.add("fuga")
67
- omit("View#sort is broken!!!")
68
- assert_equal(["XXX"],
69
- entries.sort(["_key"], :limit => 2).collect {|entry| entry["_key"]})
70
- end
71
- end