diplomat 0.1.10 → 0.2.0
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/README.md +2 -2
- data/lib/diplomat/service.rb +6 -1
- data/lib/diplomat/version.rb +1 -1
- metadata +38 -26
- data/.gitignore +0 -35
- data/.rspec +0 -2
- data/.travis.yml +0 -8
- data/Gemfile +0 -4
- data/Rakefile +0 -5
- data/diplomat.gemspec +0 -29
- data/spec/check_spec.rb +0 -71
- data/spec/health_spec.rb +0 -150
- data/spec/kv_spec.rb +0 -59
- data/spec/members_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f2bf40d8cc3eea258753340fb38086dc71c8f2f
|
4
|
+
data.tar.gz: e3db694a3793a961971686d989adfcbc98292c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea31b94d60f6f5bc15ac1d1ec3632dc8b02eff9dac5d7cce5e1979ba1fe5c74a54f6d83f35f9314e8c5b5563c669c5af711bfed879bec9a6bbfd2fb77d1bf7a0
|
7
|
+
data.tar.gz: c27de31b09f4d25a59964d61a59d3d393bc158a3774b41bb53c82ef5e19cfaa68b2246e139142c2e9cc88f45b10c46d9139a8a7b7efb6ff8004993992daa862f
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
#### What's Diplomat for?
|
11
11
|
|
12
|
-
Diplomat allows any ruby application to interact with [Consul's](http://www.consul.io/) distributed key value store, and also receive information about services currently available in the
|
12
|
+
Diplomat allows any ruby application to interact with [Consul's](http://www.consul.io/) distributed key value store, and also receive information about services currently available in the Consul cluster.
|
13
13
|
|
14
14
|
#### Does it work in rails?
|
15
15
|
|
@@ -31,7 +31,7 @@ production:
|
|
31
31
|
<% end %>
|
32
32
|
```
|
33
33
|
|
34
|
-
#### Why would I use
|
34
|
+
#### Why would I use Consul over ZooKeeper, Doozerd, etcd, Nagios, Sensu, SmartStack, SkyDNS, Chef, Puppet, Ansible, etc?
|
35
35
|
|
36
36
|
[Read up what makes Consul different here](http://www.consul.io/intro/vs/index.html)
|
37
37
|
|
data/lib/diplomat/service.rb
CHANGED
@@ -6,9 +6,14 @@ module Diplomat
|
|
6
6
|
|
7
7
|
# Get a service by it's key
|
8
8
|
# @param key [String] the key
|
9
|
+
# @param scope [Symbol] :first or :all results
|
9
10
|
# @return [OpenStruct] all data associated with the service
|
10
|
-
def get key
|
11
|
+
def get key, scope=:first
|
11
12
|
ret = @conn.get "/v1/catalog/service/#{key}"
|
13
|
+
|
14
|
+
if scope == :all
|
15
|
+
return JSON.parse(ret.body).map { |service| OpenStruct.new service }
|
16
|
+
end
|
12
17
|
return OpenStruct.new JSON.parse(ret.body).first
|
13
18
|
end
|
14
19
|
|
data/lib/diplomat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diplomat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hamelink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,33 +81,61 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.3.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.3.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: fivemat
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: gem-release
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
117
|
+
version: '0.7'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
124
|
+
version: '0.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.8'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.8'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: faraday
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,14 +157,8 @@ executables: []
|
|
129
157
|
extensions: []
|
130
158
|
extra_rdoc_files: []
|
131
159
|
files:
|
132
|
-
- ".gitignore"
|
133
|
-
- ".rspec"
|
134
|
-
- ".travis.yml"
|
135
|
-
- Gemfile
|
136
160
|
- LICENSE
|
137
161
|
- README.md
|
138
|
-
- Rakefile
|
139
|
-
- diplomat.gemspec
|
140
162
|
- lib/diplomat.rb
|
141
163
|
- lib/diplomat/check.rb
|
142
164
|
- lib/diplomat/health.rb
|
@@ -145,11 +167,6 @@ files:
|
|
145
167
|
- lib/diplomat/rest_client.rb
|
146
168
|
- lib/diplomat/service.rb
|
147
169
|
- lib/diplomat/version.rb
|
148
|
-
- spec/check_spec.rb
|
149
|
-
- spec/health_spec.rb
|
150
|
-
- spec/kv_spec.rb
|
151
|
-
- spec/members_spec.rb
|
152
|
-
- spec/spec_helper.rb
|
153
170
|
homepage: https://github.com/johnhamelink/diplomat
|
154
171
|
licenses:
|
155
172
|
- BSD
|
@@ -170,14 +187,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
187
|
version: '0'
|
171
188
|
requirements: []
|
172
189
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.2.
|
190
|
+
rubygems_version: 2.2.2
|
174
191
|
signing_key:
|
175
192
|
specification_version: 4
|
176
193
|
summary: Diplomat is a simple wrapper for Consul
|
177
|
-
test_files:
|
178
|
-
- spec/check_spec.rb
|
179
|
-
- spec/health_spec.rb
|
180
|
-
- spec/kv_spec.rb
|
181
|
-
- spec/members_spec.rb
|
182
|
-
- spec/spec_helper.rb
|
194
|
+
test_files: []
|
183
195
|
has_rdoc:
|
data/.gitignore
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
Gemfile.lock
|
2
|
-
*.gem
|
3
|
-
*.rbc
|
4
|
-
/.config
|
5
|
-
/coverage/
|
6
|
-
/InstalledFiles
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
|
13
|
-
## Specific to RubyMotion:
|
14
|
-
.dat*
|
15
|
-
.repl_history
|
16
|
-
build/
|
17
|
-
|
18
|
-
## Documentation cache and generated files:
|
19
|
-
/.yardoc/
|
20
|
-
/_yardoc/
|
21
|
-
/doc/
|
22
|
-
/rdoc/
|
23
|
-
|
24
|
-
## Environment normalisation:
|
25
|
-
/.bundle/
|
26
|
-
/lib/bundler/man/
|
27
|
-
|
28
|
-
# for a library or gem, you might want to ignore these files since the code is
|
29
|
-
# intended to run in multiple environments; otherwise, check them in:
|
30
|
-
# Gemfile.lock
|
31
|
-
# .ruby-version
|
32
|
-
# .ruby-gemset
|
33
|
-
|
34
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
-
.rvmrc
|
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/diplomat.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'diplomat/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "diplomat"
|
8
|
-
spec.version = Diplomat::VERSION
|
9
|
-
spec.authors = ["John Hamelink"]
|
10
|
-
spec.email = ["john@johnhamelink.com"]
|
11
|
-
spec.description = %q{Diplomat is a simple wrapper for Consul}
|
12
|
-
spec.summary = %q{Diplomat is a simple wrapper for Consul}
|
13
|
-
spec.homepage = "https://github.com/johnhamelink/diplomat"
|
14
|
-
spec.license = "BSD"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.3"
|
23
|
-
spec.add_development_dependency "pry", "~> 0.9"
|
24
|
-
spec.add_development_dependency "rspec", "~> 2.14"
|
25
|
-
spec.add_development_dependency "fakes-rspec", "~> 1.0"
|
26
|
-
spec.add_development_dependency "json", "~> 1.8"
|
27
|
-
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.3.0"
|
28
|
-
spec.add_dependency "faraday", "~> 0.9"
|
29
|
-
end
|
data/spec/check_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
describe Diplomat::Check do
|
6
|
-
|
7
|
-
let(:faraday) { fake }
|
8
|
-
|
9
|
-
context "check" do
|
10
|
-
|
11
|
-
it "checks" do
|
12
|
-
json = JSON.generate(
|
13
|
-
{
|
14
|
-
"service:redis"=> {
|
15
|
-
"Node"=>"foobar",
|
16
|
-
"CheckID"=>"service:redis",
|
17
|
-
"Name"=>"Service 'redis' check",
|
18
|
-
"Status"=>"passing",
|
19
|
-
"Notes"=>"",
|
20
|
-
"Output"=>"",
|
21
|
-
"ServiceID"=>"redis",
|
22
|
-
"ServiceName"=>"redis"}
|
23
|
-
}
|
24
|
-
)
|
25
|
-
|
26
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
27
|
-
|
28
|
-
check = Diplomat::Check.new(faraday)
|
29
|
-
|
30
|
-
expect(check.checks["service:redis"]["Node"]).to eq("foobar")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "register_script" do
|
34
|
-
faraday.stub(:put).and_return(OpenStruct.new({ body: '', status: 200 }))
|
35
|
-
check = Diplomat::Check.new(faraday)
|
36
|
-
expect(check.register_script("foobar-1", "Foobar", "Foobar test", "/script/test", "10s")).to eq(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "register_ttl" do
|
40
|
-
faraday.stub(:put).and_return(OpenStruct.new({ body: '', status: 200 }))
|
41
|
-
check = Diplomat::Check.new(faraday)
|
42
|
-
expect(check.register_ttl("foobar-1", "Foobar", "Foobar test", "15s")).to eq(true)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "deregister" do
|
46
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: '', status: 200 }))
|
47
|
-
check = Diplomat::Check.new(faraday)
|
48
|
-
expect(check.deregister("foobar-1")).to eq(true)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "pass" do
|
52
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: '', status: 200 }))
|
53
|
-
check = Diplomat::Check.new(faraday)
|
54
|
-
expect(check.pass("foobar-1")).to eq(true)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "warn" do
|
58
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: '', status: 200 }))
|
59
|
-
check = Diplomat::Check.new(faraday)
|
60
|
-
expect(check.warn("foobar-1")).to eq(true)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "fail" do
|
64
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: '', status: 200 }))
|
65
|
-
check = Diplomat::Check.new(faraday)
|
66
|
-
expect(check.fail("foobar-1")).to eq(true)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
data/spec/health_spec.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
describe Diplomat::Health do
|
6
|
-
|
7
|
-
let(:faraday) { fake }
|
8
|
-
|
9
|
-
context "health" do
|
10
|
-
|
11
|
-
it "node" do
|
12
|
-
json = <<EOF
|
13
|
-
[
|
14
|
-
{
|
15
|
-
"Node": "foobar",
|
16
|
-
"CheckID": "serfHealth",
|
17
|
-
"Name": "Serf Health Status",
|
18
|
-
"Status": "passing",
|
19
|
-
"Notes": "",
|
20
|
-
"Output": "",
|
21
|
-
"ServiceID": "",
|
22
|
-
"ServiceName": ""
|
23
|
-
},
|
24
|
-
{
|
25
|
-
"Node": "foobar",
|
26
|
-
"CheckID": "service:redis",
|
27
|
-
"Name": "Service 'redis' check",
|
28
|
-
"Status": "passing",
|
29
|
-
"Notes": "",
|
30
|
-
"Output": "",
|
31
|
-
"ServiceID": "redis",
|
32
|
-
"ServiceName": "redis"
|
33
|
-
}
|
34
|
-
]
|
35
|
-
EOF
|
36
|
-
|
37
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
38
|
-
|
39
|
-
health = Diplomat::Health.new(faraday)
|
40
|
-
|
41
|
-
expect(health.node("foobar")[0]["Node"]).to eq("foobar")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "checks" do
|
45
|
-
json = <<EOF
|
46
|
-
[
|
47
|
-
{
|
48
|
-
"Node": "foobar",
|
49
|
-
"CheckID": "service:redis",
|
50
|
-
"Name": "Service 'redis' check",
|
51
|
-
"Status": "passing",
|
52
|
-
"Notes": "",
|
53
|
-
"Output": "",
|
54
|
-
"ServiceID": "redis",
|
55
|
-
"ServiceName": "redis"
|
56
|
-
}
|
57
|
-
]
|
58
|
-
EOF
|
59
|
-
|
60
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
61
|
-
|
62
|
-
health = Diplomat::Health.new(faraday)
|
63
|
-
|
64
|
-
expect(health.checks("foobar")[0]["Node"]).to eq("foobar")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "service" do
|
68
|
-
json = <<EOF
|
69
|
-
[
|
70
|
-
{
|
71
|
-
"Node": {
|
72
|
-
"Node": "foobar",
|
73
|
-
"Address": "10.1.10.12"
|
74
|
-
},
|
75
|
-
"Service": {
|
76
|
-
"ID": "redis",
|
77
|
-
"Service": "redis",
|
78
|
-
"Tags": null,
|
79
|
-
"Port": 8000
|
80
|
-
},
|
81
|
-
"Checks": [
|
82
|
-
{
|
83
|
-
"Node": "foobar",
|
84
|
-
"CheckID": "service:redis",
|
85
|
-
"Name": "Service 'redis' check",
|
86
|
-
"Status": "passing",
|
87
|
-
"Notes": "",
|
88
|
-
"Output": "",
|
89
|
-
"ServiceID": "redis",
|
90
|
-
"ServiceName": "redis"
|
91
|
-
},
|
92
|
-
{
|
93
|
-
"Node": "foobar",
|
94
|
-
"CheckID": "serfHealth",
|
95
|
-
"Name": "Serf Health Status",
|
96
|
-
"Status": "passing",
|
97
|
-
"Notes": "",
|
98
|
-
"Output": "",
|
99
|
-
"ServiceID": "",
|
100
|
-
"ServiceName": ""
|
101
|
-
}
|
102
|
-
]
|
103
|
-
}
|
104
|
-
]
|
105
|
-
EOF
|
106
|
-
|
107
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
108
|
-
|
109
|
-
health = Diplomat::Health.new(faraday)
|
110
|
-
|
111
|
-
expect(health.service("foobar")[0]["Node"]["Node"]).to eq("foobar")
|
112
|
-
end
|
113
|
-
|
114
|
-
it "state" do
|
115
|
-
json = <<EOF
|
116
|
-
[
|
117
|
-
{
|
118
|
-
"Node": "foobar",
|
119
|
-
"CheckID": "serfHealth",
|
120
|
-
"Name": "Serf Health Status",
|
121
|
-
"Status": "passing",
|
122
|
-
"Notes": "",
|
123
|
-
"Output": "",
|
124
|
-
"ServiceID": "",
|
125
|
-
"ServiceName": ""
|
126
|
-
},
|
127
|
-
{
|
128
|
-
"Node": "foobar",
|
129
|
-
"CheckID": "service:redis",
|
130
|
-
"Name": "Service 'redis' check",
|
131
|
-
"Status": "passing",
|
132
|
-
"Notes": "",
|
133
|
-
"Output": "",
|
134
|
-
"ServiceID": "redis",
|
135
|
-
"ServiceName": "redis"
|
136
|
-
}
|
137
|
-
]
|
138
|
-
EOF
|
139
|
-
|
140
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
141
|
-
|
142
|
-
health = Diplomat::Health.new(faraday)
|
143
|
-
|
144
|
-
expect(health.state("foobar")[0]["Node"]).to eq("foobar")
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
data/spec/kv_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
describe Diplomat::Kv do
|
6
|
-
|
7
|
-
let(:faraday) { fake }
|
8
|
-
|
9
|
-
context "keys" do
|
10
|
-
let(:key) { "key" }
|
11
|
-
let(:key_url) { "/v1/kv/#{key}" }
|
12
|
-
let(:key_params) { "toast" }
|
13
|
-
|
14
|
-
it "GET" do
|
15
|
-
json = JSON.generate([{
|
16
|
-
"Key" => key,
|
17
|
-
"Value" => Base64.encode64(key_params),
|
18
|
-
"Flags" => 0
|
19
|
-
}])
|
20
|
-
|
21
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
22
|
-
|
23
|
-
kv = Diplomat::Kv.new(faraday)
|
24
|
-
|
25
|
-
expect(kv.get("key")).to eq("toast")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "PUT" do
|
29
|
-
|
30
|
-
json = JSON.generate([{
|
31
|
-
"Key" => key,
|
32
|
-
"Value" => Base64.encode64(key_params),
|
33
|
-
"Flags" => 0
|
34
|
-
}])
|
35
|
-
|
36
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
37
|
-
faraday.stub(:put).and_return(OpenStruct.new({ body: "true\n"}))
|
38
|
-
kv = Diplomat::Kv.new(faraday)
|
39
|
-
|
40
|
-
expect(kv.put(key, key_params)).to eq(key_params)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "namespaces" do
|
44
|
-
json = JSON.generate([{
|
45
|
-
"Key" => key,
|
46
|
-
"Value" => Base64.encode64(key_params),
|
47
|
-
"Flags" => 0
|
48
|
-
}])
|
49
|
-
|
50
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
51
|
-
faraday.stub(:put).and_return(OpenStruct.new({ body: "true\n"}))
|
52
|
-
kv = Diplomat::Kv.new(faraday)
|
53
|
-
|
54
|
-
expect(kv.put("toast/#{key}", key_params)).to eq(key_params)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
data/spec/members_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
describe Diplomat::Members do
|
6
|
-
|
7
|
-
let(:faraday) { fake }
|
8
|
-
|
9
|
-
context "member" do
|
10
|
-
|
11
|
-
it "GET" do
|
12
|
-
json = JSON.generate(
|
13
|
-
[{
|
14
|
-
"Name" => "foobar",
|
15
|
-
"Addr" => "10.1.10.12",
|
16
|
-
"Port" => 8301,
|
17
|
-
"Tags" => {
|
18
|
-
"bootstrap" => "1",
|
19
|
-
"dc" => "dc1",
|
20
|
-
"port" => 8300,
|
21
|
-
"role" => "consul",
|
22
|
-
},
|
23
|
-
"Status" => 1,
|
24
|
-
"ProtocolMin" => 1,
|
25
|
-
"ProtocolMax" => 2,
|
26
|
-
"ProtocolCur" => 2,
|
27
|
-
"DelegateMin" => 1,
|
28
|
-
"DelegateMax" => 3,
|
29
|
-
"DelegateCur" => 3
|
30
|
-
}]
|
31
|
-
)
|
32
|
-
|
33
|
-
faraday.stub(:get).and_return(OpenStruct.new({ body: json }))
|
34
|
-
|
35
|
-
members = Diplomat::Members.new(faraday)
|
36
|
-
|
37
|
-
expect(members.get[0]["Name"]).to eq("foobar")
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
Bundler.setup
|
3
|
-
|
4
|
-
require "codeclimate-test-reporter"
|
5
|
-
CodeClimate::TestReporter.start
|
6
|
-
|
7
|
-
require 'diplomat'
|
8
|
-
require 'fakes-rspec'
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
-
config.run_all_when_everything_filtered = true
|
13
|
-
config.filter_run :focus
|
14
|
-
config.order = 'random'
|
15
|
-
end
|