groonga-command 1.1.2 → 1.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.
@@ -0,0 +1,56 @@
1
+ # Copyright (C) 2015 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 as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class LogPutCommandTest < Test::Unit::TestCase
18
+ private
19
+ def log_put_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::LogPut.new("log_put",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ level = "debug"
28
+ message = "Hello!"
29
+
30
+ ordered_arguments = [
31
+ level,
32
+ message,
33
+ ]
34
+ command = log_put_command({}, ordered_arguments)
35
+ assert_equal({
36
+ :level => level,
37
+ :message => message,
38
+ },
39
+ command.arguments)
40
+ end
41
+ end
42
+
43
+ class LevelTest < self
44
+ def test_reader
45
+ command = log_put_command(:level => "debug")
46
+ assert_equal("debug", command.level)
47
+ end
48
+ end
49
+
50
+ class MessageTest < self
51
+ def test_reader
52
+ command = log_put_command(:message => "Hello!")
53
+ assert_equal("Hello!", command.message)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,209 @@
1
+ # Copyright (C) 2015 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 as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class LogicalSelectCommandTest < Test::Unit::TestCase
18
+ private
19
+ def logical_select_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::LogicalSelect.new("logical_select",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ logical_table = "Logs"
28
+ shard_key = "timestamp",
29
+ min = "2015-02-12 00:00:00"
30
+ min_border = "include"
31
+ max = "2015-02-13 00:00:00"
32
+ max_border = "exclude"
33
+ filter = "action == 'Shutdown'"
34
+ sortby = "_score"
35
+ output_columns = "_key, name"
36
+ offset = "10"
37
+ limit = "20"
38
+ drilldown = "name"
39
+ drilldown_sortby = "_nsubrecs"
40
+ drilldown_output_columns = "name, _nsubrecs"
41
+ drilldown_offset = "5"
42
+ drilldown_limit = "10"
43
+ drilldown_calc_types = "MIN,AVG"
44
+ drilldown_calc_target = "n_occurred"
45
+
46
+ ordered_arguments = [
47
+ logical_table,
48
+ shard_key,
49
+ min,
50
+ min_border,
51
+ max,
52
+ max_border,
53
+ filter,
54
+ sortby,
55
+ output_columns,
56
+ offset,
57
+ limit,
58
+ drilldown,
59
+ drilldown_sortby,
60
+ drilldown_output_columns,
61
+ drilldown_offset,
62
+ drilldown_limit,
63
+ drilldown_calc_types,
64
+ drilldown_calc_target,
65
+ ]
66
+ command = logical_select_command({}, ordered_arguments)
67
+ assert_equal({
68
+ :logical_table => logical_table,
69
+ :shard_key => shard_key,
70
+ :min => min,
71
+ :min_border => min_border,
72
+ :max => max,
73
+ :max_border => max_border,
74
+ :filter => filter,
75
+ :sortby => sortby,
76
+ :output_columns => output_columns,
77
+ :offset => offset,
78
+ :limit => limit,
79
+ :drilldown => drilldown,
80
+ :drilldown_sortby => drilldown_sortby,
81
+ :drilldown_output_columns => drilldown_output_columns,
82
+ :drilldown_offset => drilldown_offset,
83
+ :drilldown_limit => drilldown_limit,
84
+ :drilldown_calc_types => drilldown_calc_types,
85
+ :drilldown_calc_target => drilldown_calc_target,
86
+ },
87
+ command.arguments)
88
+ end
89
+ end
90
+
91
+ class LogicalTableTest < self
92
+ def test_reader
93
+ command = logical_select_command(:logical_table => "Logs")
94
+ assert_equal("Logs", command.logical_table)
95
+ end
96
+ end
97
+
98
+ class ShardKeyTest < self
99
+ def test_reader
100
+ command = logical_select_command(:shard_key => "timestamp")
101
+ assert_equal("timestamp", command.shard_key)
102
+ end
103
+ end
104
+
105
+ class MinTest < self
106
+ def test_reader
107
+ command = logical_select_command(:min => "2015-02-13 00:00:00")
108
+ assert_equal("2015-02-13 00:00:00", command.min)
109
+ end
110
+ end
111
+
112
+ class MaxTest < self
113
+ def test_reader
114
+ command = logical_select_command(:max => "2015-01-26 00:00:00")
115
+ assert_equal("2015-01-26 00:00:00", command.max)
116
+ end
117
+ end
118
+
119
+ class MaxBorderTest < self
120
+ def test_reader
121
+ command = logical_select_command(:max_border => "include")
122
+ assert_equal("include", command.max_border)
123
+ end
124
+ end
125
+
126
+ class FilterTest < self
127
+ def test_reader
128
+ command = logical_select_command(:filter => "action == 'Shutdown'")
129
+ assert_equal("action == 'Shutdown'", command.filter)
130
+ end
131
+ end
132
+
133
+ class SortbyTest < self
134
+ def test_reader
135
+ command = logical_select_command(:sortby => "_score")
136
+ assert_equal("_score", command.sortby)
137
+ end
138
+ end
139
+
140
+ class OutputColumnsTest < self
141
+ def test_reader
142
+ command = logical_select_command(:output_columns => "_key, name")
143
+ assert_equal("_key, name", command.output_columns)
144
+ end
145
+ end
146
+
147
+ class OffsetTest < self
148
+ def test_reader
149
+ command = logical_select_command(:offset => "10")
150
+ assert_equal(10, command.offset)
151
+ end
152
+ end
153
+
154
+ class LimitTest < self
155
+ def test_reader
156
+ command = logical_select_command(:limit => "20")
157
+ assert_equal(20, command.limit)
158
+ end
159
+ end
160
+
161
+ class DrilldownTest < self
162
+ def test_reader
163
+ command = logical_select_command(:drilldown => "name")
164
+ assert_equal("name", command.drilldown)
165
+ end
166
+ end
167
+
168
+ class DrilldownSortbyTest < self
169
+ def test_reader
170
+ command = logical_select_command(:drilldown_sortby => "_nsubrecs")
171
+ assert_equal("_nsubrecs", command.drilldown_sortby)
172
+ end
173
+ end
174
+
175
+ class DrilldownOutputColumnsTest < self
176
+ def test_reader
177
+ command = logical_select_command(:drilldown_output_columns => "name, _nsubrecs")
178
+ assert_equal("name, _nsubrecs", command.drilldown_output_columns)
179
+ end
180
+ end
181
+
182
+ class DrilldownOffsetTest < self
183
+ def test_reader
184
+ command = logical_select_command(:drilldown_offset => "5")
185
+ assert_equal(5, command.drilldown_offset)
186
+ end
187
+ end
188
+
189
+ class DrilldownLimitTest < self
190
+ def test_reader
191
+ command = logical_select_command(:drilldown_limit => "10")
192
+ assert_equal(10, command.drilldown_limit)
193
+ end
194
+ end
195
+
196
+ class DrilldownCalcTypesTest < self
197
+ def test_reader
198
+ command = logical_select_command(:drilldown_calc_types => "MIN,AVG")
199
+ assert_equal("MIN,AVG", command.drilldown_calc_types)
200
+ end
201
+ end
202
+
203
+ class DrilldownCalcTargetTest < self
204
+ def test_reader
205
+ command = logical_select_command(:drilldown_calc_target => "n_occurred")
206
+ assert_equal("n_occurred", command.drilldown_calc_target)
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,46 @@
1
+ # Copyright (C) 2015 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 as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class LogicalShardListCommandTest < Test::Unit::TestCase
18
+ private
19
+ def logical_shard_list_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::LogicalShardList.new("logical_shard_list",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ logical_table = "Logs"
28
+
29
+ ordered_arguments = [
30
+ logical_table,
31
+ ]
32
+ command = logical_shard_list_command({}, ordered_arguments)
33
+ assert_equal({
34
+ :logical_table => logical_table,
35
+ },
36
+ command.arguments)
37
+ end
38
+ end
39
+
40
+ class LogicalTableTest < self
41
+ def test_reader
42
+ command = logical_shard_list_command(:logical_table => "Logs")
43
+ assert_equal("Logs", command.logical_table)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright (C) 2015 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 as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class LogicalTableRemoveCommandTest < Test::Unit::TestCase
18
+ private
19
+ def logical_table_remove_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::LogicalTableRemove.new("logical_table_remove",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ logical_table = "Logs"
28
+ shard_key = "timestamp"
29
+ min = "2015-02-12 00:00:00"
30
+ min_border = "include"
31
+ max = "2015-02-13 00:00:00"
32
+ max_border = "exclude"
33
+
34
+ ordered_arguments = [
35
+ logical_table,
36
+ shard_key,
37
+ min,
38
+ min_border,
39
+ max,
40
+ max_border,
41
+ ]
42
+ command = logical_table_remove_command({}, ordered_arguments)
43
+ assert_equal({
44
+ :logical_table => logical_table,
45
+ :shard_key => shard_key,
46
+ :min => min,
47
+ :min_border => min_border,
48
+ :max => max,
49
+ :max_border => max_border,
50
+ },
51
+ command.arguments)
52
+ end
53
+ end
54
+
55
+ class LogicalTableTest < self
56
+ def test_reader
57
+ command = logical_table_remove_command(:logical_table => "Logs")
58
+ assert_equal("Logs", command.logical_table)
59
+ end
60
+ end
61
+
62
+ class ShardKeyTest < self
63
+ def test_reader
64
+ command = logical_table_remove_command(:shard_key => "timestamp")
65
+ assert_equal("timestamp", command.shard_key)
66
+ end
67
+ end
68
+
69
+ class MinTest < self
70
+ def test_reader
71
+ command = logical_table_remove_command(:min => "2015-02-13 00:00:00")
72
+ assert_equal("2015-02-13 00:00:00", command.min)
73
+ end
74
+ end
75
+
76
+ class MaxTest < self
77
+ def test_reader
78
+ command = logical_table_remove_command(:max => "2015-01-26 00:00:00")
79
+ assert_equal("2015-01-26 00:00:00", command.max)
80
+ end
81
+ end
82
+
83
+ class MaxBorderTest < self
84
+ def test_reader
85
+ command = logical_table_remove_command(:max_border => "include")
86
+ assert_equal("include", command.max_border)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,43 @@
1
+ # Copyright (C) 2015 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 as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class ObjectExistCommandTest < Test::Unit::TestCase
18
+ private
19
+ def object_exist_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::ObjectExist.new("object_exist",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ name = "Users"
28
+
29
+ command = object_exist_command({}, [name])
30
+ assert_equal({
31
+ :name => name,
32
+ },
33
+ command.arguments)
34
+ end
35
+ end
36
+
37
+ class NameTest < self
38
+ def test_reader
39
+ command = object_exist_command(:name => "Users")
40
+ assert_equal("Users", command.name)
41
+ end
42
+ end
43
+ end