elastomer-client 0.7.0 → 0.8.1
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.
- checksums.yaml +4 -4
- data/.overcommit.yml +5 -0
- data/.rubocop.yml +83 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/elastomer-client.gemspec +4 -2
- data/lib/elastomer/client.rb +42 -37
- data/lib/elastomer/client/bulk.rb +2 -2
- data/lib/elastomer/client/cluster.rb +19 -19
- data/lib/elastomer/client/delete_by_query.rb +7 -7
- data/lib/elastomer/client/docs.rb +81 -24
- data/lib/elastomer/client/errors.rb +2 -2
- data/lib/elastomer/client/index.rb +65 -29
- data/lib/elastomer/client/multi_percolate.rb +127 -0
- data/lib/elastomer/client/multi_search.rb +2 -2
- data/lib/elastomer/client/nodes.rb +4 -4
- data/lib/elastomer/client/percolator.rb +77 -0
- data/lib/elastomer/client/repository.rb +7 -7
- data/lib/elastomer/client/scroller.rb +14 -14
- data/lib/elastomer/client/snapshot.rb +9 -9
- data/lib/elastomer/client/template.rb +3 -3
- data/lib/elastomer/client/warmer.rb +5 -16
- data/lib/elastomer/core_ext/time.rb +1 -1
- data/lib/elastomer/middleware/encode_json.rb +5 -5
- data/lib/elastomer/middleware/opaque_id.rb +3 -3
- data/lib/elastomer/middleware/parse_json.rb +5 -5
- data/lib/elastomer/notifications.rb +4 -4
- data/lib/elastomer/version.rb +1 -1
- data/script/bootstrap +2 -0
- data/script/console +5 -5
- data/test/assertions.rb +26 -24
- data/test/client/bulk_test.rb +111 -111
- data/test/client/cluster_test.rb +58 -58
- data/test/client/delete_by_query_test.rb +53 -53
- data/test/client/docs_test.rb +279 -203
- data/test/client/errors_test.rb +1 -1
- data/test/client/index_test.rb +143 -109
- data/test/client/multi_percolate_test.rb +130 -0
- data/test/client/multi_search_test.rb +30 -28
- data/test/client/nodes_test.rb +30 -29
- data/test/client/percolator_test.rb +52 -0
- data/test/client/repository_test.rb +23 -23
- data/test/client/scroller_test.rb +40 -40
- data/test/client/snapshot_test.rb +15 -15
- data/test/client/stubbed_client_test.rb +15 -15
- data/test/client/template_test.rb +10 -10
- data/test/client/warmer_test.rb +18 -18
- data/test/client_test.rb +53 -53
- data/test/core_ext/time_test.rb +12 -12
- data/test/middleware/encode_json_test.rb +20 -20
- data/test/middleware/opaque_id_test.rb +10 -10
- data/test/middleware/parse_json_test.rb +14 -14
- data/test/notifications_test.rb +32 -32
- data/test/test_helper.rb +24 -24
- metadata +38 -2
@@ -0,0 +1,130 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Elastomer::Client::MultiPercolate do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@name = "elastomer-mpercolate-test"
|
7
|
+
@index = $client.index(@name)
|
8
|
+
|
9
|
+
unless @index.exists?
|
10
|
+
@index.create \
|
11
|
+
:settings => { "index.number_of_shards" => 1, "index.number_of_replicas" => 0 },
|
12
|
+
:mappings => {
|
13
|
+
:doc1 => {
|
14
|
+
:_source => { :enabled => true }, :_all => { :enabled => false },
|
15
|
+
:properties => {
|
16
|
+
:title => { :type => "string", :analyzer => "standard" },
|
17
|
+
:author => { :type => "string", :index => "not_analyzed" }
|
18
|
+
}
|
19
|
+
},
|
20
|
+
:doc2 => {
|
21
|
+
:_source => { :enabled => true }, :_all => { :enabled => false },
|
22
|
+
:properties => {
|
23
|
+
:title => { :type => "string", :analyzer => "standard" },
|
24
|
+
:author => { :type => "string", :index => "not_analyzed" }
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
wait_for_index(@name)
|
30
|
+
end
|
31
|
+
|
32
|
+
@docs = @index.docs
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
@index.delete if @index.exists?
|
37
|
+
end
|
38
|
+
|
39
|
+
it "performs multi percolate queries" do
|
40
|
+
populate!
|
41
|
+
|
42
|
+
body = [
|
43
|
+
'{"percolate" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
44
|
+
'{"doc": {"author": "pea53"}}',
|
45
|
+
'{"percolate" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
46
|
+
'{"doc": {"author": "grantr"}}',
|
47
|
+
'{"count" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
48
|
+
'{"doc": {"author": "grantr"}}',
|
49
|
+
nil
|
50
|
+
]
|
51
|
+
body = body.join "\n"
|
52
|
+
h = $client.multi_percolate body
|
53
|
+
response1, response2, response3 = h["responses"]
|
54
|
+
assert_equal ["1", "2"], response1["matches"].map { |match| match["_id"] }.sort
|
55
|
+
assert_equal ["1", "3"], response2["matches"].map { |match| match["_id"] }.sort
|
56
|
+
assert_equal 2, response3["total"]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "performs multi percolate queries with .mpercolate" do
|
60
|
+
populate!
|
61
|
+
|
62
|
+
body = [
|
63
|
+
'{"percolate" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
64
|
+
'{"doc": {"author": "pea53"}}',
|
65
|
+
'{"percolate" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
66
|
+
'{"doc": {"author": "grantr"}}',
|
67
|
+
'{"count" : {"index": "elastomer-mpercolate-test", "type": "doc2"}}',
|
68
|
+
'{"doc": {"author": "grantr"}}',
|
69
|
+
nil
|
70
|
+
]
|
71
|
+
body = body.join "\n"
|
72
|
+
h = $client.mpercolate body
|
73
|
+
response1, response2, response3 = h["responses"]
|
74
|
+
assert_equal ["1", "2"], response1["matches"].map { |match| match["_id"] }.sort
|
75
|
+
assert_equal ["1", "3"], response2["matches"].map { |match| match["_id"] }.sort
|
76
|
+
assert_equal 2, response3["total"]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "supports a nice block syntax" do
|
80
|
+
populate!
|
81
|
+
|
82
|
+
h = $client.multi_percolate(:index => @name, :type => "doc2") do |m|
|
83
|
+
m.percolate :author => "pea53"
|
84
|
+
m.percolate :author => "grantr"
|
85
|
+
m.count({ :author => "grantr" })
|
86
|
+
end
|
87
|
+
|
88
|
+
response1, response2, response3 = h["responses"]
|
89
|
+
assert_equal ["1", "2"], response1["matches"].map { |match| match["_id"] }.sort
|
90
|
+
assert_equal ["1", "3"], response2["matches"].map { |match| match["_id"] }.sort
|
91
|
+
assert_equal 2, response3["total"]
|
92
|
+
end
|
93
|
+
|
94
|
+
# rubocop:disable Metrics/MethodLength
|
95
|
+
def populate!
|
96
|
+
@docs.index \
|
97
|
+
:_id => 1,
|
98
|
+
:_type => "doc1",
|
99
|
+
:title => "the author of gravatar",
|
100
|
+
:author => "mojombo"
|
101
|
+
|
102
|
+
@docs.index \
|
103
|
+
:_id => 2,
|
104
|
+
:_type => "doc1",
|
105
|
+
:title => "the author of resque",
|
106
|
+
:author => "defunkt"
|
107
|
+
|
108
|
+
@docs.index \
|
109
|
+
:_id => 1,
|
110
|
+
:_type => "doc2",
|
111
|
+
:title => "the author of logging",
|
112
|
+
:author => "pea53"
|
113
|
+
|
114
|
+
@docs.index \
|
115
|
+
:_id => 2,
|
116
|
+
:_type => "doc2",
|
117
|
+
:title => "the author of rubber-band",
|
118
|
+
:author => "grantr"
|
119
|
+
|
120
|
+
percolator1 = @index.percolator "1"
|
121
|
+
percolator1.create :query => { :match_all => { } }
|
122
|
+
percolator2 = @index.percolator "2"
|
123
|
+
percolator2.create :query => { :match => { :author => "pea53" } }
|
124
|
+
percolator2 = @index.percolator "3"
|
125
|
+
percolator2.create :query => { :match => { :author => "grantr" } }
|
126
|
+
|
127
|
+
@index.refresh
|
128
|
+
end
|
129
|
+
# rubocop:enable Metrics/MethodLength
|
130
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Elastomer::Client::MultiSearch do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@name =
|
6
|
+
@name = "elastomer-msearch-test"
|
7
7
|
@index = $client.index(@name)
|
8
8
|
|
9
9
|
unless @index.exists?
|
10
10
|
@index.create \
|
11
|
-
:settings => {
|
11
|
+
:settings => { "index.number_of_shards" => 1, "index.number_of_replicas" => 0 },
|
12
12
|
:mappings => {
|
13
13
|
:doc1 => {
|
14
14
|
:_source => { :enabled => true }, :_all => { :enabled => false },
|
15
15
|
:properties => {
|
16
|
-
:title => { :type =>
|
17
|
-
:author => { :type =>
|
16
|
+
:title => { :type => "string", :analyzer => "standard" },
|
17
|
+
:author => { :type => "string", :index => "not_analyzed" }
|
18
18
|
}
|
19
19
|
},
|
20
20
|
:doc2 => {
|
21
21
|
:_source => { :enabled => true }, :_all => { :enabled => false },
|
22
22
|
:properties => {
|
23
|
-
:title => { :type =>
|
24
|
-
:author => { :type =>
|
23
|
+
:title => { :type => "string", :analyzer => "standard" },
|
24
|
+
:author => { :type => "string", :index => "not_analyzed" }
|
25
25
|
}
|
26
26
|
}
|
27
27
|
}
|
@@ -36,7 +36,7 @@ describe Elastomer::Client::MultiSearch do
|
|
36
36
|
@index.delete if @index.exists?
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "performs multisearches" do
|
40
40
|
populate!
|
41
41
|
|
42
42
|
body = [
|
@@ -54,7 +54,7 @@ describe Elastomer::Client::MultiSearch do
|
|
54
54
|
assert_equal "2", response2["hits"]["hits"][0]["_id"]
|
55
55
|
|
56
56
|
body = [
|
57
|
-
|
57
|
+
"{}",
|
58
58
|
'{"query" : {"match": {"author" : "grantr"}}}',
|
59
59
|
nil
|
60
60
|
]
|
@@ -65,7 +65,7 @@ describe Elastomer::Client::MultiSearch do
|
|
65
65
|
assert_equal "2", response1["hits"]["hits"][0]["_id"]
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
68
|
+
it "performs multisearches with .msearch" do
|
69
69
|
populate!
|
70
70
|
|
71
71
|
body = [
|
@@ -83,7 +83,7 @@ describe Elastomer::Client::MultiSearch do
|
|
83
83
|
assert_equal "2", response2["hits"]["hits"][0]["_id"]
|
84
84
|
|
85
85
|
body = [
|
86
|
-
|
86
|
+
"{}",
|
87
87
|
'{"query" : {"match": {"author" : "grantr"}}}',
|
88
88
|
nil
|
89
89
|
]
|
@@ -94,12 +94,12 @@ describe Elastomer::Client::MultiSearch do
|
|
94
94
|
assert_equal "2", response1["hits"]["hits"][0]["_id"]
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it "supports a nice block syntax" do
|
98
98
|
populate!
|
99
99
|
|
100
100
|
h = $client.multi_search do |m|
|
101
101
|
m.search({:query => { :match_all => {}}}, :index => @name, :search_type => :count)
|
102
|
-
m.search({:query => { :match => { "title" => "author" }}}, :index => @name, :type =>
|
102
|
+
m.search({:query => { :match => { "title" => "author" }}}, :index => @name, :type => "doc2")
|
103
103
|
end
|
104
104
|
|
105
105
|
response1, response2 = h["responses"]
|
@@ -109,7 +109,7 @@ describe Elastomer::Client::MultiSearch do
|
|
109
109
|
|
110
110
|
h = @index.multi_search do |m|
|
111
111
|
m.search({:query => { :match_all => {}}}, :search_type => :count)
|
112
|
-
m.search({:query => { :match => { "title" => "author" }}}, :type =>
|
112
|
+
m.search({:query => { :match => { "title" => "author" }}}, :type => "doc2")
|
113
113
|
end
|
114
114
|
|
115
115
|
response1, response2 = h["responses"]
|
@@ -117,9 +117,9 @@ describe Elastomer::Client::MultiSearch do
|
|
117
117
|
assert_equal 4, response1["hits"]["total"]
|
118
118
|
assert_equal 2, response2["hits"]["total"]
|
119
119
|
|
120
|
-
h = @index.docs(
|
120
|
+
h = @index.docs("doc1").multi_search do |m|
|
121
121
|
m.search({:query => { :match_all => {}}}, :search_type => :count)
|
122
|
-
m.search({:query => { :match => { "title" => "logging" }}}, :type =>
|
122
|
+
m.search({:query => { :match => { "title" => "logging" }}}, :type => "doc2")
|
123
123
|
end
|
124
124
|
|
125
125
|
response1, response2 = h["responses"]
|
@@ -128,31 +128,33 @@ describe Elastomer::Client::MultiSearch do
|
|
128
128
|
assert_equal 1, response2["hits"]["total"]
|
129
129
|
end
|
130
130
|
|
131
|
+
# rubocop:disable Metrics/MethodLength
|
131
132
|
def populate!
|
132
133
|
@docs.index \
|
133
134
|
:_id => 1,
|
134
|
-
:_type =>
|
135
|
-
:title =>
|
136
|
-
:author =>
|
135
|
+
:_type => "doc1",
|
136
|
+
:title => "the author of gravatar",
|
137
|
+
:author => "mojombo"
|
137
138
|
|
138
139
|
@docs.index \
|
139
140
|
:_id => 2,
|
140
|
-
:_type =>
|
141
|
-
:title =>
|
142
|
-
:author =>
|
141
|
+
:_type => "doc1",
|
142
|
+
:title => "the author of resque",
|
143
|
+
:author => "defunkt"
|
143
144
|
|
144
145
|
@docs.index \
|
145
146
|
:_id => 1,
|
146
|
-
:_type =>
|
147
|
-
:title =>
|
148
|
-
:author =>
|
147
|
+
:_type => "doc2",
|
148
|
+
:title => "the author of logging",
|
149
|
+
:author => "pea53"
|
149
150
|
|
150
151
|
@docs.index \
|
151
152
|
:_id => 2,
|
152
|
-
:_type =>
|
153
|
-
:title =>
|
154
|
-
:author =>
|
153
|
+
:_type => "doc2",
|
154
|
+
:title => "the author of rubber-band",
|
155
|
+
:author => "grantr"
|
155
156
|
|
156
157
|
@index.refresh
|
157
158
|
end
|
159
|
+
# rubocop:enable Metrics/MethodLength
|
158
160
|
end
|
data/test/client/nodes_test.rb
CHANGED
@@ -1,57 +1,58 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Elastomer::Client::Nodes do
|
4
4
|
|
5
|
-
it
|
5
|
+
it "gets info for the node(s)" do
|
6
6
|
h = $client.nodes.info
|
7
|
-
assert h.key?(
|
8
|
-
assert_instance_of Hash, h[
|
7
|
+
assert h.key?("cluster_name"), "the cluster name is returned"
|
8
|
+
assert_instance_of Hash, h["nodes"], "the node list is returned"
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it "gets stats for the node(s)" do
|
12
12
|
h = $client.nodes.stats
|
13
|
-
assert_instance_of Hash, h[
|
13
|
+
assert_instance_of Hash, h["nodes"], "the node list is returned"
|
14
14
|
|
15
|
-
node = h[
|
16
|
-
assert node.key?(
|
15
|
+
node = h["nodes"].values.first
|
16
|
+
assert node.key?("indices"), "indices stats are returned"
|
17
17
|
end
|
18
18
|
|
19
19
|
if es_version_1_x?
|
20
|
-
it
|
21
|
-
h = $client.nodes.info(:info =>
|
22
|
-
node = h[
|
23
|
-
assert node.key?(
|
24
|
-
assert !node.key?(
|
20
|
+
it "fitlers node info" do
|
21
|
+
h = $client.nodes.info(:info => "os")
|
22
|
+
node = h["nodes"].values.first
|
23
|
+
assert node.key?("os"), "expected os info to be present"
|
24
|
+
assert !node.key?("jvm"), "expected jvm info to be absent"
|
25
25
|
|
26
26
|
h = $client.nodes.info(:info => %w[jvm process])
|
27
|
-
node = h[
|
28
|
-
assert node.key?(
|
29
|
-
assert node.key?(
|
30
|
-
assert !node.key?(
|
27
|
+
node = h["nodes"].values.first
|
28
|
+
assert node.key?("jvm"), "expected jvm info to be present"
|
29
|
+
assert node.key?("process"), "expected process info to be present"
|
30
|
+
assert !node.key?("network"), "expected network info to be absent"
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
34
|
-
h = $client.nodes.stats(:stats =>
|
35
|
-
node = h[
|
36
|
-
assert node.key?(
|
37
|
-
assert !node.key?(
|
33
|
+
it "filters node stats" do
|
34
|
+
h = $client.nodes.stats(:stats => "http")
|
35
|
+
node = h["nodes"].values.first
|
36
|
+
assert node.key?("http"), "expected http stats to be present"
|
37
|
+
assert !node.key?("indices"), "expected indices stats to be absent"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it "gets the hot threads for the node(s)" do
|
42
42
|
str = $client.nodes.hot_threads :read_timeout => 2
|
43
43
|
assert_instance_of String, str
|
44
|
-
|
44
|
+
assert !str.nil?, "expected response to not be nil"
|
45
|
+
assert !str.empty?, "expected response to not be empty"
|
45
46
|
end
|
46
47
|
|
47
|
-
it
|
48
|
-
h = $client.nodes(
|
49
|
-
assert_empty h[
|
48
|
+
it "can be scoped to a single node" do
|
49
|
+
h = $client.nodes("node-with-no-name").info
|
50
|
+
assert_empty h["nodes"]
|
50
51
|
end
|
51
52
|
|
52
|
-
it
|
53
|
+
it "can be scoped to multiple nodes" do
|
53
54
|
h = $client.nodes(%w[node1 node2 node3]).info
|
54
|
-
assert_empty h[
|
55
|
+
assert_empty h["nodes"]
|
55
56
|
end
|
56
57
|
|
57
58
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
describe Elastomer::Client::Percolator do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@index = $client.index "elastomer-percolator-test"
|
7
|
+
@index.delete if @index.exists?
|
8
|
+
@docs = @index.docs("docs")
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
@index.delete if @index.exists?
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when an index exists" do
|
16
|
+
before do
|
17
|
+
@index.create(nil)
|
18
|
+
wait_for_index(@index_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "creates a query" do
|
22
|
+
percolator = @index.percolator "1"
|
23
|
+
response = percolator.create :query => { :match_all => { } }
|
24
|
+
assert response["created"], "Couldn't create the percolator query"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "gets a query" do
|
28
|
+
percolator = @index.percolator "1"
|
29
|
+
percolator.create :query => { :match_all => { } }
|
30
|
+
response = percolator.get
|
31
|
+
assert response["found"], "Couldn't find the percolator query"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "deletes a query" do
|
35
|
+
percolator = @index.percolator "1"
|
36
|
+
percolator.create :query => { :match_all => { } }
|
37
|
+
response = percolator.delete
|
38
|
+
assert response["found"], "Couldn't find the percolator query"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "checks for the existence of a query" do
|
42
|
+
percolator = @index.percolator "1"
|
43
|
+
refute percolator.exists?, "Percolator query exists"
|
44
|
+
percolator.create :query => { :match_all => { } }
|
45
|
+
assert percolator.exists?, "Percolator query does not exist"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "cannot delete all percolators by providing a nil id" do
|
49
|
+
assert_raises(ArgumentError) { percolator = @index.percolator nil }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Elastomer::Client::Repository do
|
4
4
|
|
@@ -9,11 +9,11 @@ describe Elastomer::Client::Repository do
|
|
9
9
|
skip "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
|
10
10
|
end
|
11
11
|
|
12
|
-
@name =
|
12
|
+
@name = "elastomer-repository-test"
|
13
13
|
@repo = $client.repository(@name)
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it "determines if a repo exists" do
|
17
17
|
assert_equal false, @repo.exists?
|
18
18
|
assert_equal false, @repo.exist?
|
19
19
|
with_tmp_repo(@name) do
|
@@ -21,63 +21,63 @@ describe Elastomer::Client::Repository do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it "creates repos" do
|
25
25
|
response = create_repo(@name)
|
26
26
|
assert_equal true, response["acknowledged"]
|
27
27
|
delete_repo(@name)
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it "cannot create a repo without a name" do
|
31
31
|
lambda {
|
32
32
|
create_repo(nil)
|
33
33
|
}.must_raise ArgumentError
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it "gets repos" do
|
37
37
|
with_tmp_repo do |repo|
|
38
38
|
response = repo.get
|
39
39
|
refute_nil response[repo.name]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it "gets all repos" do
|
44
44
|
with_tmp_repo do |repo|
|
45
45
|
response = $client.repository.get
|
46
46
|
refute_nil response[repo.name]
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it "gets repo status" do
|
51
51
|
with_tmp_repo do |repo|
|
52
52
|
response = repo.status
|
53
53
|
assert_equal [], response["snapshots"]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
it
|
57
|
+
it "gets status of all repos" do
|
58
58
|
response = $client.repository.status
|
59
59
|
assert_equal [], response["snapshots"]
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
62
|
+
it "updates repos" do
|
63
63
|
with_tmp_repo do |repo|
|
64
|
-
settings = repo.get[repo.name][
|
65
|
-
response = repo.update(:type =>
|
64
|
+
settings = repo.get[repo.name]["settings"]
|
65
|
+
response = repo.update(:type => "fs", :settings => settings.merge("compress" => true))
|
66
66
|
assert_equal true, response["acknowledged"]
|
67
67
|
assert_equal "true", repo.get[repo.name]["settings"]["compress"]
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
71
|
+
it "cannot update a repo without a name" do
|
72
72
|
with_tmp_repo do |repo|
|
73
73
|
lambda {
|
74
|
-
settings = repo.get[repo.name][
|
75
|
-
$client.repository.update(:type =>
|
74
|
+
settings = repo.get[repo.name]["settings"]
|
75
|
+
$client.repository.update(:type => "fs", :settings => settings.merge("compress" => true))
|
76
76
|
}.must_raise ArgumentError
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
80
|
+
it "deletes repos" do
|
81
81
|
with_tmp_repo do |repo|
|
82
82
|
response = repo.delete
|
83
83
|
assert_equal true, response["acknowledged"]
|
@@ -85,26 +85,26 @@ describe Elastomer::Client::Repository do
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "cannot delete a repo without a name" do
|
89
89
|
lambda {
|
90
90
|
$client.repository.delete
|
91
91
|
}.must_raise ArgumentError
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it "gets snapshots" do
|
95
95
|
with_tmp_repo do |repo|
|
96
96
|
response = repo.snapshots.get
|
97
97
|
assert_equal [], response["snapshots"]
|
98
98
|
|
99
|
-
create_snapshot(repo,
|
99
|
+
create_snapshot(repo, "test-snapshot")
|
100
100
|
response = repo.snapshot.get
|
101
|
-
assert_equal [
|
101
|
+
assert_equal ["test-snapshot"], response["snapshots"].collect { |info| info["snapshot"] }
|
102
102
|
|
103
|
-
snapshot2 = create_snapshot(repo,
|
103
|
+
snapshot2 = create_snapshot(repo, "test-snapshot2")
|
104
104
|
response = repo.snapshots.get
|
105
105
|
snapshot_names = response["snapshots"].collect { |info| info["snapshot"] }
|
106
|
-
assert_includes snapshot_names,
|
107
|
-
assert_includes snapshot_names,
|
106
|
+
assert_includes snapshot_names, "test-snapshot"
|
107
|
+
assert_includes snapshot_names, "test-snapshot2"
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|