Skip to content

Commit

Permalink
cleaning up and more testing api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mose committed Feb 23, 2016
1 parent fbb5a8c commit 96ea415
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/apiv1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def check_authorization
hiera = Hieracles::Hiera.new(hieracles_config)
nodeinfo = Hieracles::Node.new(node, hieracles_config)
facts = Hieraviz::Facts.new(settings.configdata['tmpdir'], base, node, get_username)
puts facts.instance_variable_get(:@filename)
res = {
'hiera' => hiera.hierarchy,
'vars' => hiera.params,
Expand Down
39 changes: 37 additions & 2 deletions spec/app/apiv1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@
it { expect(File).to exist(factsfile) }
end


describe "DELETE /v1/node/node1.example.com/facts" do
let(:tmpdir) { "spec/files/tmp" }
let(:base) { "" }
Expand All @@ -230,7 +229,6 @@
it { expect(File).not_to exist(factsfile) }
end


describe "GET /v1/farms" do
let(:expected) { { "farm1" => 0 } }
before do
Expand All @@ -248,6 +246,43 @@
it { expect(last_response).to be_ok }
it { expect(JSON.parse last_response.body).to eq expected }
end

describe "GET /v1/node/node1.example.com/hierarchy" do
let(:expected) {
{
"hiera" => [
"nodes/%{fqdn}",
"farm/%{farm}",
"common/common"
],
"vars" => [
"fqdn",
"farm"
],
"info" => {
"fqdn" => "node1.example.com",
"country" => "fr",
"datacenter" => "equinix",
"farm" => "dev",
"classes" => [
"farm1"
]
},
"files" => [
"params/nodes/node1.example.com.yaml"
],
"facts" => {},
"defaults" => nil
}
}
before do
get '/node/node1.example.com/hierarchy'
end
it { expect(last_response).to be_ok }
it { expect(JSON.parse last_response.body).to eq expected }
end


end

end

0 comments on commit 96ea415

Please sign in to comment.