spec/container_spec.rb in testlab-1.5.0 vs spec/container_spec.rb in testlab-1.5.1
- old
+ new
@@ -20,11 +20,12 @@
require "spec_helper"
describe TestLab::Container do
subject {
- @ui = ZTK::UI.new(:stdout => StringIO.new, :stderr => StringIO.new)
+ @logger = ZTK::Logger.new('/tmp/test.log')
+ @ui = ZTK::UI.new(:stdout => StringIO.new, :stderr => StringIO.new, :logger => @logger)
@testlab = TestLab.new(:repo_dir => REPO_DIR, :labfile_path => LABFILE_PATH, :ui => @ui)
@testlab.boot
@testlab.containers.first
}
@@ -50,10 +51,11 @@
describe "methods" do
describe "#status" do
it "should return a hash of status information about the container" do
+ subject.node.stub(:dead?) { false }
subject.node.stub(:state) { :running }
subject.lxc.stub(:state) { :not_created }
subject.lxc_clone.stub(:exists?) { false }
subject.status.should be_kind_of(Hash)
@@ -148,59 +150,74 @@
end
end
describe "#create" do
it "should create the container" do
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
- subject.lxc.config.stub(:save) { true }
- subject.stub(:detect_arch) { "amd64" }
+ subject.node.ssh.stub(:exec)
+
subject.lxc.stub(:create) { true }
subject.lxc.stub(:state) { :not_created }
+ subject.lxc.config.stub(:save) { true }
+
subject.lxc_clone.stub(:exists?) { false }
- subject.node.ssh.stub(:exec)
+
+ subject.stub(:detect_arch) { "amd64" }
subject.stub(:provisioners) { Array.new }
subject.create
end
end
describe "#destroy" do
it "should destroy the container" do
+ subject.node.stub(:alive?) { true }
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(:dead?) { false }
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
+ subject.node.stub(:arch) { "x86_64" }
+ subject.node.stub(:exec) { }
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.lxc_clone.stub(:exists?) { false }
+ subject.stub(:exec) { }
+ subject.stub(:configure) { }
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(:dead?) { false }
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:stop) { true }
subject.lxc.stub(:wait) { true }
@@ -215,10 +232,11 @@
end
describe "#provision" do
context "with no provisioner" do
it "should provision the container" do
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
@@ -232,10 +250,11 @@
context "with the shell provisioner" do
it "should provision the container" do
subject and (subject = TestLab::Container.first('server-shell'))
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
@@ -249,10 +268,11 @@
end
describe "#deprovision" do
context "with no provisioner" do
it "should deprovision the container" do
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }
@@ -266,9 +286,10 @@
context "with the shell provisioner" do
it "should deprovision the container" do
subject and (subject = TestLab::Container.first('server-shell'))
+ subject.node.stub(:alive?) { true }
subject.node.stub(:state) { :running }
subject.lxc.stub(:exists?) { true }
subject.lxc.stub(:state) { :stopped }