/
test_slice.rb
103 lines (93 loc) · 2.45 KB
/
test_slice.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright (C) 2014 Droonga Project
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require "droonga/catalog/dataset"
class CatalogSliceTest < Test::Unit::TestCase
private
def create_slice(data)
minimum_dataset_data = {
"replicas" => {
},
}
dataset = Droonga::Catalog::Dataset.new("DatasetName", minimum_dataset_data)
Droonga::Catalog::Slice.new(dataset, data)
end
class WeightTest < self
def test_default
data = {
}
slice = create_slice(data)
assert_equal(1, slice.weight)
end
def test_specified
data = {
"weight" => 29,
}
slice = create_slice(data)
assert_equal(29, slice.weight)
end
end
class LabelTest < self
def test_default
data = {
}
slice = create_slice(data)
assert_nil(slice.label)
end
def test_specified
data = {
"label" => "High",
}
slice = create_slice(data)
assert_equal("High", slice.label)
end
end
class BoundaryTest < self
def test_default
data = {
}
slice = create_slice(data)
assert_nil(slice.boundary)
end
def test_specified
data = {
"boundary" => "2014-03-21",
}
slice = create_slice(data)
assert_equal("2014-03-21", slice.boundary)
end
end
class VolumeTest < self
def test_single
data = {
"volume" => {
"address" => "127.0.0.1:10047/volume.000",
},
}
slice = create_slice(data)
assert_equal("127.0.0.1:10047/volume.000",
slice.volume.address.to_s)
end
def test_all_nodes
data = {
"volume" => {
"address" => "127.0.0.1:10047/volume.000",
},
}
slice = create_slice(data)
assert_equal(["127.0.0.1:10047/volume"],
slice.all_nodes)
end
end
end