Skip to content

Commit

Permalink
Merge pull request #36 from atheiman/tags-not-nil
Browse files Browse the repository at this point in the history
spec for unspecified tags
  • Loading branch information
atheiman authored Nov 26, 2017
2 parents 65fbe7e + 48744c6 commit 00c75e2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 52 deletions.
8 changes: 8 additions & 0 deletions spec/chef-fixtures/chef-objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ nodes:
deep:
nested:
attribute: 0
'node-3':
chef_environment: '_default'
run_list:
- 'recipe[global_cookbook]'
default:
deep:
nested:
attribute: 0
89 changes: 37 additions & 52 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,41 @@
@server.start_background
end

let(:main_nodes) do
{"bcr-node"=>
{"environment"=>"bcr_env",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[bcr_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["bcr-tag", "global-tag"]},
"node-1"=>
{"environment"=>"env_one",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_one_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-1-tag", "global-tag"]},
"node-2"=>
{"environment"=>"env_two",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_two_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-2-tag", "global-tag"]},
"node-3"=>
{"environment"=>"_default",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>[]}}
end

context 'with nodes loaded into chef server' do
it '/ should respond ok' do
get '/'
Expand All @@ -37,65 +72,15 @@
expect(last_response).to be_ok
expect(last_response.headers['Content-Type']).to match(/text\/yaml/)
nodes = YAML.load(last_response.body)
expect(nodes).to eq(
{"bcr-node"=>
{"environment"=>"bcr_env",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[bcr_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["bcr-tag", "global-tag"]},
"node-1"=>
{"environment"=>"env_one",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_one_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-1-tag", "global-tag"]},
"node-2"=>
{"environment"=>"env_two",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_two_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-2-tag", "global-tag"]}}
)
expect(nodes).to eq(main_nodes)
end

it '/main/*:* should return the same result as /*:*' do
get '/main/*:*'
expect(last_response).to be_ok
expect(last_response.headers['Content-Type']).to match(/text\/yaml/)
nodes = YAML.load(last_response.body)
expect(nodes).to eq(
{"bcr-node"=>
{"environment"=>"bcr_env",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[bcr_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["bcr-tag", "global-tag"]},
"node-1"=>
{"environment"=>"env_one",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_one_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-1-tag", "global-tag"]},
"node-2"=>
{"environment"=>"env_two",
"fqdn"=>nil,
"ip"=>nil,
"run_list"=>["recipe[global_cookbook]", "role[node_two_role]"],
"roles"=>nil,
"platform"=>nil,
"tags"=>["node-2-tag", "global-tag"]}}
)
expect(nodes).to eq(main_nodes)
end

it 'filter result should be created based on GET params' do
Expand Down

0 comments on commit 00c75e2

Please sign in to comment.