-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
check_def_spec.rb
65 lines (53 loc) · 1.94 KB
/
check_def_spec.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
require 'spec_helper'
require 'chefspec/berkshelf'
describe_resource "consul_check_def" do
describe "with id" do
let(:check_def_path) { "/etc/consul.d/check-uniqueid.json" }
describe "create" do
let(:example_recipe) { "consul_spec::check_def_with_id_create" }
it "removes any check previously registered by name" do
expect(chef_run).to delete_file("/etc/consul.d/check-dummy name.json")
end
it "register the check" do
['"name": "dummy name"',
'"id": "uniqueid"',
'"script": "curl http://localhost:8888/health"',
'"http": "http://localhost:8888/health"',
'"interval": "10s"',
'"ttl": "50s"',
'"notes": "Blahblah"'].each do |content|
expect(chef_run).to render_file(check_def_path)
.with_content(content)
end
end
end
describe "delete" do
let(:example_recipe) { "consul_spec::check_def_with_id_delete" }
it "de-register the check" do
expect(chef_run).to delete_file(check_def_path)
end
end
end
describe "without id" do
let(:check_def_path) { "/etc/consul.d/check-dummy name.json" }
describe "create" do
let(:example_recipe) { "consul_spec::check_def_without_id_create" }
it "does not remove checks previously registered by name" do
expect(chef_run).not_to delete_file("/etc/consul.d/check-dummy name.json")
end
it "register the check" do
['"name": "dummy name"', '"script": "curl http://localhost:8888/health"',
'"interval": "10s"', '"ttl": "50s"', '"notes": "Blahblah"'].each do |content|
expect(chef_run).to render_file(check_def_path)
.with_content(content)
end
end
end
describe "delete" do
let(:example_recipe) { "consul_spec::check_def_without_id_delete" }
it "de-register the check" do
expect(chef_run).to delete_file(check_def_path)
end
end
end
end