Commit 6cbca4db authored by John E. Vincent's avatar John E. Vincent

last few tests for the night

parent 82be084e
......@@ -39,15 +39,11 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
end
it "invalid application should not work" do
get '/c/badapp'
last_response.should_not be_ok
last_response.status.should == 404
response = last_response.should return_json
last_response.should be_missing
end
it "invalid configuration for application should not work" do
get '/c/badapp/badconfig'
last_response.should_not be_ok
last_response.status.should == 404
response = last_response.should return_json
last_response.should be_missing
end
end
......@@ -78,18 +74,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
it "new configuration with missing format should not work" do
config_data = {:body => "a string"}.to_json
put '/c/newnewapp/someconfig', config_data, "CONTENT_TYPE" => "application/json"
last_response.should_not be_ok
response = last_response.should return_json
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
last_response.should be_invalid
end
it "new configuration with missing body should not work" do
config_data = {:body => "a string"}.to_json
put '/c/newnewapp/someconfig', config_data, "CONTENT_TYPE" => "application/json"
last_response.should_not be_ok
response = last_response.should return_json
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
last_response.should be_invalid
end
end
......
......@@ -66,21 +66,13 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
it "host missing name parameter should not work" do
host_data = {:status => "pending"}.to_json
put '/h/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
last_response.should_not be_ok
response = last_response.should return_json
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
last_response.should be_invalid
end
it "host missing status parameter should not work" do
host_data = {:name => "host100.domain.com"}.to_json
put '/h/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
last_response.should_not be_ok
response = last_response.should return_json
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
last_response.should be_invalid
end
it "host with invalid status parameter should not work" do
......
......@@ -7,6 +7,10 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
it "all services should work"
it "all named services should work"
it "named service for host should work"
it "missing service for host should not work" do
get '/s/foobar/baz'
last_response.should be_missing
end
end
describe "PUT" do
......@@ -19,8 +23,27 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
end
describe "DELETE" do
it "existing host should work"
it "invalid host should not work"
before(:all) do
@h = Host.create(:name => "h1", :status => "up")
@h.services << Service.create(:name => "s1", :status => "up", :host => @h)
@h.save
@s = @h.services.first
end
it "existing host should work" do
delete "/s/#{@s.name}/#{@h.name}"
last_response.should be_ok
response = last_response.should return_json
response["result"].should == "success"
response["action"].should == "delete"
response["id"].should == @s.id
response["host"].should == @h.name
response["service"].should == @s.name
end
it "invalid host should not work" do
delete "/s/#{@s.name}/#{@h.name}"
last_response.should be_missing
end
end
end
......
......@@ -92,4 +92,13 @@ RSpec::Matchers.define :be_missing do
response["result"].should == "failure"
response["error_message"].should == "Resource not found"
end
end
RSpec::Matchers.define :be_invalid do
match do |last_response|
last_response.headers["Content-Type"].should == "application/json"
response = JSON.parse(last_response.body)
response["result"].should == "failure"
response["error_message"].should == "Missing Parameters"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment