-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from thedebugger/update_last_action
Update last action so that notifications can work
- Loading branch information
Showing
8 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
source 'https://supermarket.getchef.com' | ||
|
||
metadata | ||
|
||
group :test do | ||
cookbook "consul_spec", path: "spec/fixtures/cookbooks/consul_spec" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if defined?(ChefSpec) | ||
def create_consul_service_def(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new(:consul_service_def, :create, resource_name) | ||
end | ||
|
||
def delete_consul_service_def(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new(:consul_service_def, :delete, resource_name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name 'consul_spec' | ||
|
||
depends 'consul' |
7 changes: 7 additions & 0 deletions
7
spec/fixtures/cookbooks/consul_spec/recipes/service_def_create.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_recipe "consul" | ||
consul_service_def "dummy" do | ||
id "uniqueid" | ||
port 8888 | ||
tags ['releases', 'v1'] | ||
check :interval => "10s", :script => "curl http://localhost:8888/health" | ||
end |
5 changes: 5 additions & 0 deletions
5
spec/fixtures/cookbooks/consul_spec/recipes/service_def_delete.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include_recipe "consul" | ||
consul_service_def "dummy" do | ||
id "uniqueid" | ||
action :delete | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
require 'chefspec/berkshelf' | ||
|
||
describe_resource "consul_service_def" do | ||
let(:service_def_path) { "/etc/consul.d/service-uniqueid.json" } | ||
|
||
describe "create" do | ||
let(:example_recipe) { "consul_spec::service_def_create" } | ||
|
||
it "register the service" do | ||
['"name": "dummy"', '"port": 8888', | ||
'"script": "curl http://localhost:8888/health"'].each do |content| | ||
expect(chef_run).to render_file(service_def_path) | ||
.with_content(content) | ||
|
||
expect(chef_run.file(service_def_path)) | ||
.to notify('service[consul]').to(:reload).delayed | ||
end | ||
end | ||
end | ||
|
||
describe "delete" do | ||
let(:example_recipe) { "consul_spec::service_def_delete" } | ||
|
||
it "de-register the service" do | ||
expect(chef_run).to delete_file(service_def_path) | ||
expect(chef_run.file(service_def_path)) | ||
.to notify('service[consul]').to(:reload).delayed | ||
end | ||
end | ||
end |