Sha256: d7b7d9246174bcced2f4ae47ce4ba1d636d3fa6f6f04ecbef28743cebb573a89

Contents?: true

Size: 1.7 KB

Versions: 27

Compression:

Stored size: 1.7 KB

Contents

require "test_helper"

class ShellProvisionerTest < Test::Unit::TestCase
  setup do
    clean_paths

    @klass = Vagrant::Provisioners::Shell
    @action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
    @config = @klass::Config.new
    @config.top = Vagrant::Config::Top.new(@action_env.env)
    @action = @klass.new(@action_env, @config)

    @config.path = "foo"
  end

  context "config" do
    setup do
      @errors = Vagrant::Config::ErrorRecorder.new

      # Start in a valid state (verified by a test below)
      @config.path = "foo"
      File.open(@config.expanded_path, "w") { |f| f.puts "HELLO" }
    end

    should "be valid" do
      @config.validate(@errors)
      assert @errors.errors.empty?
    end

    should "be invalid if the path is not set" do
      @config.path = nil

      @config.validate(@errors)
      assert !@errors.errors.empty?
    end

    should "be invalid if the path does not exist" do
      @config.path = "bar"

      @config.validate(@errors)
      assert !@errors.errors.empty?
    end

    should "be invalid if the upload path is not set" do
      @config.upload_path = nil

      @config.validate(@errors)
      assert !@errors.errors.empty?
    end
  end

  context "provisioning" do
    setup do
      @ssh = mock("ssh")
      @action.vm.ssh.stubs(:execute).yields(@ssh)
    end

    should "upload the file, chmod, then execute it" do
      commands = ["chmod +x #{@config.upload_path}", @config.upload_path]

      p_seq = sequence("provisioning")
      @action.vm.ssh.expects(:upload!).with(@config.expanded_path.to_s, @config.upload_path).in_sequence(p_seq)
      @ssh.expects(:sudo!).with(commands).in_sequence(p_seq)

      @action.provision!
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
vagrantup-0.8.5 test/vagrant/provisioners/shell_test.rb
vagrantup-0.8.4 test/vagrant/provisioners/shell_test.rb
vagrantup-0.8.3 test/vagrant/provisioners/shell_test.rb
vagrantup-0.8.2 test/vagrant/provisioners/shell_test.rb
vagrantup-0.8.1 test/vagrant/provisioners/shell_test.rb
vagrantup-0.8.0 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.8 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.7 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.6 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.5 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.4 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.3 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.2 test/vagrant/provisioners/shell_test.rb
vagrantup-0.7.1 test/vagrant/provisioners/shell_test.rb
vagrant-0.8.5 test/vagrant/provisioners/shell_test.rb
vagrant-0.8.2 test/vagrant/provisioners/shell_test.rb
vagrant-0.8.1 test/vagrant/provisioners/shell_test.rb
vagrant-0.7.8 test/vagrant/provisioners/shell_test.rb
vagrant-0.7.7 test/vagrant/provisioners/shell_test.rb
vagrant-0.7.6 test/vagrant/provisioners/shell_test.rb