Commit bad01f0d authored by John E. Vincent's avatar John E. Vincent

quick cleanup of test structure

parent 9fc817d8
...@@ -48,46 +48,30 @@ ...@@ -48,46 +48,30 @@
<tfoot> <tfoot>
<tr> <tr>
<td class="left_align">TOTAL</td> <td class="left_align">TOTAL</td>
<td class='right_align'><tt>610</tt></td> <td class='right_align'><tt>612</tt></td>
<td class='right_align'><tt>518</tt></td> <td class='right_align'><tt>521</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>55.25%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>83.33%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:17px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>50.58%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class='coverage_total'>81.96%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:51px"></div> <div class="covered" style="width:82px"></div>
<div class="uncovered" style="width:49px"></div> <div class="uncovered" style="width:18px"></div>
</div></td> </div></td>
</tr> </tr>
</tfoot> </tfoot>
<tbody> <tbody>
<tr class="all_files all_coverage 50 60 70 80 90 100 even"> <tr class="all_files all_coverage 60 70 80 90 100 lib even">
<td class="left_align"><a href="noah_rb.html">noah.rb</a></td>
<td class='right_align'><tt>325</tt></td>
<td class='right_align'><tt>283</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>48.31%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:48px"></div>
<div class="uncovered" style="width:52px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>42.40%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:42px"></div>
<div class="uncovered" style="width:58px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 60 70 80 90 100 lib odd">
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td> <td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td>
<td class='right_align'><tt>55</tt></td> <td class='right_align'><tt>55</tt></td>
<td class='right_align'><tt>45</tt></td> <td class='right_align'><tt>45</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>54.55%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>56.36%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:44px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
...@@ -96,19 +80,35 @@ ...@@ -96,19 +80,35 @@
</div></td> </div></td>
</tr> </tr>
<tr class="all_files all_coverage 70 80 90 100 lib even"> <tr class="all_files all_coverage 90 100 odd">
<td class="left_align"><a href="noah_rb.html">noah.rb</a></td>
<td class='right_align'><tt>326</tt></td>
<td class='right_align'><tt>285</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>82.52%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:83px"></div>
<div class="uncovered" style="width:17px"></div>
</div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>81.05%</tt></div>
<div class="percent_graph">
<div class="covered" style="width:81px"></div>
<div class="uncovered" style="width:19px"></div>
</div></td>
</tr>
<tr class="all_files all_coverage 90 100 lib even">
<td class="left_align"><a href="lib-models_rb.html">lib/models.rb</a></td> <td class="left_align"><a href="lib-models_rb.html">lib/models.rb</a></td>
<td class='right_align'><tt>230</tt></td> <td class='right_align'><tt>231</tt></td>
<td class='right_align'><tt>190</tt></td> <td class='right_align'><tt>191</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>65.22%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>90.91%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:65px"></div> <div class="covered" style="width:91px"></div>
<div class="uncovered" style="width:35px"></div> <div class="uncovered" style="width:9px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>61.05%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>89.01%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:61px"></div> <div class="covered" style="width:89px"></div>
<div class="uncovered" style="width:39px"></div> <div class="uncovered" style="width:11px"></div>
</div></td> </div></td>
</tr> </tr>
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
</table> </table>
</div> </div>
<p>Generated on 2011-01-27 21:32:12 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p> <p>Generated on 2011-01-31 05:03:32 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});}); $(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});});
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
<td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td> <td class="left_align"><a href="lib-helpers_rb.html">lib/helpers.rb</a></td>
<td class='right_align'><tt>55</tt></td> <td class='right_align'><tt>55</tt></td>
<td class='right_align'><tt>45</tt></td> <td class='right_align'><tt>45</tt></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>54.55%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>56.36%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
<div class="covered" style="width:55px"></div> <div class="covered" style="width:56px"></div>
<div class="uncovered" style="width:45px"></div> <div class="uncovered" style="width:44px"></div>
</div></td> </div></td>
<td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div> <td class="left_align"><div class="percent_graph_legend"><tt class=''>57.78%</tt></div>
<div class="percent_graph"> <div class="percent_graph">
...@@ -158,13 +158,13 @@ ...@@ -158,13 +158,13 @@
<tr class="inferred"> <tr class="marked">
<td><pre><a name="line18">18</a> end </pre></td> <td><pre><a name="line18">18</a> end </pre></td>
</tr> </tr>
<tr class="uncovered"> <tr class="marked">
<td><pre><a name="line19">19</a> </pre></td> <td><pre><a name="line19">19</a> </pre></td>
</tr> </tr>
...@@ -387,7 +387,7 @@ ...@@ -387,7 +387,7 @@
</tbody> </tbody>
</table> </table>
<p>Generated on 2011-01-27 21:32:12 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p> <p>Generated on 2011-01-31 05:03:32 -0500 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>
</body> </body>
</html> </html>
This diff is collapsed.
This diff is collapsed.
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Noah Host Model", :reset_redis => true do describe "Using the Host Model", :reset_redis => true do
it "should create a new Host with no services" do describe "should" do
hostname = "host1.domain.com" it "create a new Host with no services" do
hoststatus = "up" hostname = "host1.domain.com"
host = Host.create(:name => hostname, :status => hoststatus) hoststatus = "up"
host.valid?.should == true host = Host.create(:name => hostname, :status => hoststatus)
host.save host.valid?.should == true
host.name.should == hostname host.save
host.status.should == hoststatus host.name.should == hostname
host.services.size.should == 0 host.status.should == hoststatus
end host.services.size.should == 0
end
it "should create a new Host with services" do it "create a new Host with services" do
hostname = "host2.domain.com" hostname = "host2.domain.com"
hoststatus = "down" hoststatus = "down"
servicename = 'myservice' servicename = 'myservice'
servicestatus = 'pending' servicestatus = 'pending'
host = Host.create(:name => hostname, :status => hoststatus) host = Host.create(:name => hostname, :status => hoststatus)
host.valid?.should == true host.valid?.should == true
host.save host.save
host.services << Service.create(:name => servicename, :status => servicestatus, :host => host) host.services << Service.create(:name => servicename, :status => servicestatus, :host => host)
host.name.should == hostname host.name.should == hostname
host.status.should == hoststatus host.status.should == hoststatus
host.services.size.should == 1 host.services.size.should == 1
host.services[1].valid?.should == true host.services[1].valid?.should == true
host.services[1].name.should == servicename host.services[1].name.should == servicename
host.services[1].status.should == servicestatus host.services[1].status.should == servicestatus
host.services[1].host_id.should == host.id host.services[1].host_id.should == host.id
end end
it "should create a Host via find_or_create" do it "create a Host via find_or_create" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "up" hoststatus = "up"
host = Host.find_or_create(:name => hostname, :status => hoststatus) host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true host.valid?.should == true
host.save host.save
host.is_new?.should == true host.is_new?.should == true
end end
it "should update a Host via find_or_create" do it "update a Host via find_or_create" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "pending" hoststatus = "pending"
newstatus = "down" newstatus = "down"
host = Host.find_or_create(:name => hostname, :status => hoststatus) host = Host.find_or_create(:name => hostname, :status => hoststatus)
host.valid?.should == true host.valid?.should == true
host.save host.save
host.is_new?.should == true host.is_new?.should == true
sleep 1 sleep 1
host1 = Host.find_or_create(:name => hostname, :status => newstatus) host1 = Host.find_or_create(:name => hostname, :status => newstatus)
host1.save host1.save
host1.is_new?.should == false host1.is_new?.should == false
end end
it "should delete a Host" do it "delete a Host" do
hostname = "host3.domain.com" hostname = "host3.domain.com"
hoststatus = "pending" hoststatus = "pending"
host = Host.create(:name => hostname, :status => hoststatus) host = Host.create(:name => hostname, :status => hoststatus)
host.save host.save
host.delete host.delete
Host.find(:name => hostname).empty?.should == true Host.find(:name => hostname).empty?.should == true
end end
it "should not create a new Host with missing status" do it "should return all Hosts" do
hostname ="host3.domain.com" hostname1 = "host1.domain.com"
host = Host.create(:name => hostname) status1 = "up"
host.valid?.should == false hostname2 = "host2.domain.com"
host.errors.should == [[:status, :not_present], [:status, :not_member]] status2= "down"
host1 = Host.create(:name => hostname1, :status => status1)
host2 = Host.create(:name => hostname2, :status => status2)
host1.save
host2.save
Hosts.all.class.should == Array
Hosts.all.size.should == 2
Hosts.all.first.name.should == hostname1
Hosts.all.first.status.should == status1
Hosts.all.last.name.should == hostname2
Hosts.all.last.status.should == status2
end
end end
it "should not create a new Host with missing hostname" do describe "should not" do
status = "up" it "create a new Host with missing status" do
host = Host.create(:status => status) hostname ="host3.domain.com"
host.valid?.should == false host = Host.create(:name => hostname)
host.errors.should == [[:name, :not_present]] host.valid?.should == false
end host.errors.should == [[:status, :not_present], [:status, :not_member]]
end
it "should not create a new Host with an invalid status" do it "create a new Host with missing hostname" do
hostname = "host3.domain.com" status = "up"
status = "online" host = Host.create(:status => status)
host = Host.create(:name => hostname, :status => status) host.valid?.should == false
host.valid?.should == false host.errors.should == [[:name, :not_present]]
host.errors.should == [[:status, :not_member]] end
end
it "should not create a duplicate Host" do it "create a new Host with an invalid status" do
hostname = "host1.domain.com" hostname = "host3.domain.com"
status = "up" status = "online"
host1 = Host.create(:name => hostname, :status => status) host = Host.create(:name => hostname, :status => status)
host1.save host.valid?.should == false
host2 = Host.create(:name => hostname, :status => status) host.errors.should == [[:status, :not_member]]
host2.valid?.should == false end
host2.errors.should == [[:name, :not_unique]]
end
it "should return all Hosts" do it "create a duplicate Host" do
hostname1 = "host1.domain.com" hostname = "host1.domain.com"
status1 = "up" status = "up"
hostname2 = "host2.domain.com" host1 = Host.create(:name => hostname, :status => status)
status2= "down" host1.save
host1 = Host.create(:name => hostname1, :status => status1) host2 = Host.create(:name => hostname, :status => status)
host2 = Host.create(:name => hostname2, :status => status2) host2.valid?.should == false
host1.save host2.errors.should == [[:name, :not_unique]]
host2.save end
Hosts.all.class.should == Array
Hosts.all.size.should == 2
Hosts.all.first.name.should == hostname1
Hosts.all.first.status.should == status1
Hosts.all.last.name.should == hostname2
Hosts.all.last.status.should == status2
end end
end end
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Noah Service Model", :reset_redis => true do describe "Noah Service Model", :reset_redis => true do
describe "should" do
it "should create a new Service" do it "create a new Service" do
servicename = "myservice" servicename = "myservice"
servicestatus = "up" servicestatus = "up"
hostname = "mytesthost1" hostname = "mytesthost1"
hoststatus = "up" hoststatus = "up"
host = Host.create(:name => hostname, :status => hoststatus) host = Host.create(:name => hostname, :status => hoststatus)
host.save host.save
service = Service.create(:name => servicename, :status => servicestatus, :host => host) service = Service.create(:name => servicename, :status => servicestatus, :host => host)
service.valid?.should == true service.valid?.should == true
service.save service.save
service.name.should == servicename service.name.should == servicename
service.status.should == servicestatus service.status.should == servicestatus
service.host_id.should == host.id service.host_id.should == host.id
host.services[1].name.should == servicename host.services[1].name.should == servicename
end end
it "should not create a new Service when missing a Host" do it "create a new Service with find_or_create" do
servicename = "myservice1" host = Host.create(:name => "h1", :status => "up")
servicestatus = "up" host.save
service = Service.create(:name => servicename, :status => servicestatus) service = Service.find_or_create(:name => "s1", :status => "up", :host => host)
service.valid?.should == false service.save
service.errors.should == [[:host_id, :not_present]] service.is_new?.should == true
end end
it "should not create a new Service when missing a name" do it "update an existing Service with find_or_create" do
host = Host.create(:name => "host1.domain.com", :status => "up") host = Host.create(:name => "h2", :status => "up")
host.save host.save
service = Service.create(:status => "up", :host => host) service = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service.valid?.should == false service.save
service.errors.should == [[:name, :not_present]] sleep 1
end service2 = Service.find_or_create(:name => "s2", :status => "up", :host => host)
service2.save
service2.is_new?.should == false
end
it "should not create a new Service when missing a status" do it "delete a Service" do
host = Host.create(:name => "host1.domain.com", :status => "up") h = Host.create(:name => "h1", :status => "up")
host.save h.save
service = Service.create(:name => 'foo', :host => host) s = Service.create(:name => "s1", :status => "up", :host => h)
service.valid?.should == false s.save
service.errors.should == [[:status, :not_present], [:status, :not_member]] s = Service.find(:name => "s1").first
end s.delete
s = Service.find(:name => "s1").first
s.should == nil
end
it "should not create a new Service with an invalid status" do it "find multiple Services" do
host = Host.create(:name => "host1.domain.com", :status => "up") h = Host.create(:name => "h1", :status => "up")
host.save if h.valid?
service = Service.create(:name => "myservice", :status => "invalid_status", :host => host) h.services << Service.create(:name => "s1", :status => "up", :host => h)
service.valid?.should == false h.services << Service.create(:name => "s2", :status => "up", :host => h)
service.errors.should == [[:status, :not_member]] h.save
end end
Services.all.size.should == 2
Services.all.first.name.should == "s1"
Services.all.last.name.should == "s2"
end
it "should not create a duplicate Service" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
s = Service.create(:name => "myservice", :status => "up", :host => host)
s.save
s1 = Service.create(:name => "myservice", :status => "up", :host => host)
s1.valid?.should == false
s1.errors.should == [[[:name, :host_id], :not_unique]]
end end
it "should create a new Service with find_or_create" do describe "should not" do
host = Host.create(:name => "h1", :status => "up")
host.save
service = Service.find_or_create(:name => "s1", :status => "up", :host => host)
service.save
service.is_new?.should == true
end
it "should update an existing Service with find_or_create" do it "create a new Service when missing a Host" do
host = Host.create(:name => "h2", :status => "up") servicename = "myservice1"
host.save servicestatus = "up"
service = Service.find_or_create(:name => "s2", :status => "up", :host => host) service = Service.create(:name => servicename, :status => servicestatus)
service.save service.valid?.should == false
sleep 1 service.errors.should == [[:host_id, :not_present]]
service2 = Service.find_or_create(:name => "s2", :status => "up", :host => host) end
service2.save
service2.is_new?.should == false
end
it "should delete a Service" do it "create a new Service when missing a name" do
h = Host.create(:name => "h1", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
h.save host.save
s = Service.create(:name => "s1", :status => "up", :host => h) service = Service.create(:status => "up", :host => host)
s.save service.valid?.should == false
s = Service.find(:name => "s1").first service.errors.should == [[:name, :not_present]]
s.delete end
s = Service.find(:name => "s1").first
s.should == nil
end
it "should find multiple Services" do it "create a new Service when missing a status" do
h = Host.create(:name => "h1", :status => "up") host = Host.create(:name => "host1.domain.com", :status => "up")
if h.valid? host.save
h.services << Service.create(:name => "s1", :status => "up", :host => h) service = Service.create(:name => 'foo', :host => host)
h.services << Service.create(:name => "s2", :status => "up", :host => h) service.valid?.should == false
h.save service.errors.should == [[:status, :not_present], [:status, :not_member]]
end
it "create a new Service with an invalid status" do
host = Host.create(:name => "host1.domain.com", :status => "up")
host.save
service = Service.create(:name => "myservice", :status => "invalid_status", :host => host)
service.valid?.should == false
service.errors.should == [[:status, :not_member]]
end end
Services.all.size.should == 2
Services.all.first.name.should == "s1" it "create a duplicate Service" do
Services.all.last.name.should == "s2" host = Host.create(:name => "host1.domain.com", :status => "up")
end host.save
s = Service.create(:name => "myservice", :status => "up", :host => host)
s.save
s1 = Service.create(:name => "myservice", :status => "up", :host => host)
s1.valid?.should == false
s1.errors.should == [[[:name, :host_id], :not_unique]]
end
end
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