spec/container_spec.rb in testlab-1.4.4 vs spec/container_spec.rb in testlab-1.5.0
- old
+ new
@@ -50,20 +50,24 @@
describe "methods" do
describe "#status" do
it "should return a hash of status information about the container" do
+ subject.node.stub(:state) { :running }
subject.lxc.stub(:state) { :not_created }
subject.lxc_clone.stub(:exists?) { false }
+
subject.status.should be_kind_of(Hash)
subject.status.should_not be_empty
end
end
describe "#state" do
it "should return the state of the container" do
+ subject.node.stub(:dead?) { false }
subject.lxc.stub(:state) { :not_created }
+ subject.lxc_clone.stub(:exists?) { false }
subject.state.should == :not_created
end
end
describe "#fqdn" do
@@ -164,53 +168,64 @@
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
subject.lxc.stub(:destroy) { true }
subject.lxc_clone.stub(:exists?) { false }
+ subject.lxc_clone.stub(:destroy) { false }
subject.stub(:provisioners) { Array.new }
subject.destroy
end
end
describe "#up" do
it "should up the container" do
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:start) { true }
subject.lxc.stub(:wait) { true }
subject.lxc.stub(:state) { :running }
subject.lxc.stub(:attach)
- subject.stub(:provisioners) { Array.new }
subject.lxc_clone.stub(:exists?) { false }
+ subject.stub(:provisioners) { Array.new }
+
ZTK::TCPSocketCheck.any_instance.stub(:wait) { true }
subject.up
end
end
describe "#down" do
it "should down the container" do
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:stop) { true }
subject.lxc.stub(:wait) { true }
subject.lxc.stub(:state) { :stopped }
+
+ subject.lxc_clone.stub(:exists?) { false }
+
subject.stub(:provisioners) { Array.new }
subject.down
end
end
describe "#provision" do
context "with no provisioner" do
it "should provision the container" do
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
+
+ subject.lxc_clone.stub(:exists?) { false }
+
subject.stub(:provisioners) { Array.new }
subject.provision
end
end
@@ -218,12 +233,16 @@
context "with the shell provisioner" do
it "should provision the container" do
subject and (subject = TestLab::Container.first('server-shell'))
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
+
+ subject.lxc_clone.stub(:exists?) { false }
+
subject.stub(:provisioners) { Array.new }
subject.provision
end
end
@@ -231,12 +250,16 @@
describe "#deprovision" do
context "with no provisioner" do
it "should deprovision the container" do
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
+
+ subject.lxc_clone.stub(:exists?) { false }
+
subject.stub(:provisioners) { Array.new }
subject.deprovision
end
end
@@ -244,11 +267,15 @@
context "with the shell provisioner" do
it "should deprovision the container" do
subject and (subject = TestLab::Container.first('server-shell'))
subject.node.stub(:state) { :running }
+
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
+
+ subject.lxc_clone.stub(:exists?) { false }
+
subject.stub(:provisioners) { Array.new }
subject.deprovision
end
end