Initial test for run_install_script.

tests that the expected commands are called with
and without sudo.

Reviewed-by: Jeff McCune

Signed-off-by: Dan Bode <[email protected]>
---
 spec/unit/puppet/cloudpack_spec.rb |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/spec/unit/puppet/cloudpack_spec.rb 
b/spec/unit/puppet/cloudpack_spec.rb
index c94966a..4f88e87 100644
--- a/spec/unit/puppet/cloudpack_spec.rb
+++ b/spec/unit/puppet/cloudpack_spec.rb
@@ -171,6 +171,21 @@ describe Puppet::CloudPack do
           end.should raise_error Exception, /Must specify .*? answers file/
         end
       end
+      describe '#run install script' do
+        it 'should upload the script and execute it' do
+          @scp_mock.expects(:upload).with('foo_file', "/tmp/foo.sh")
+          @ssh_mock.expects(:run).with("bash -c 'chmod u+x /tmp/foo.sh; 
/tmp/foo.sh | tee 
/tmp/install.log'").returns([Fog::SSH::Mock::Result.new('foo')])
+          subject.run_install_script(
+            @ssh_mock, @scp_mock, 'foo_file', '/tmp', 'foo', 'root'
+          )
+        end
+        it 'should execte script with sudo when login is not root' do
+          @ssh_mock.expects(:run).with("sudo bash -c 'chmod u+x /tmp/foo.sh; 
/tmp/foo.sh | tee 
/tmp/install.log'").returns([Fog::SSH::Mock::Result.new('foo')])
+          subject.run_install_script(
+            @ssh_mock, @scp_mock, 'foo_file', '/tmp', 'foo', 'dan'
+          )
+        end
+      end
       describe '#compile_template' do
         it 'should be able to compile a template' do
           tmp_file = begin
-- 
1.7.5.4

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to