Sha256: 9b80401c81423bc34f82f57871179d3b985d9eaa6591f3175c5a831380868bbf

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

require "test_helper"

class LinuxHostTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Hosts::Linux
    @env = mock_environment
    @env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
    @env.logger.stubs(:info)

    @instance = @klass.new(@env)
  end

  context "supporting nfs check" do
    should "support NFS" do
      @instance.expects(:system).returns(true)
      assert @instance.nfs?
    end

    should "not support NFS if nfsd is not found" do
      @instance.expects(:system).returns(false)
      assert !@instance.nfs?
    end

    should "retry until a boolean is returned" do
      seq = sequence("seq")
      @instance.expects(:system).in_sequence(seq).raises(TypeError.new("foo"))
      @instance.expects(:system).in_sequence(seq).returns(true)
      assert @instance.nfs?
    end
  end

  context "nfs export" do
    setup do
      @instance.stubs(:system)

      @ip = "foo"
      @folders = "bar"
    end

    should "output the lines of the rendered template" do
      output = %W[foo bar baz].join("\n")
      Vagrant::Util::TemplateRenderer.expects(:render).with("nfs/exports_linux",
                                                            :uuid => @env.vm.uuid,
                                                            :ip => @ip,
                                                            :folders => @folders).returns(output)

      @instance.expects(:system).times(output.split("\n").length)
      @instance.expects(:system).with("sudo /etc/init.d/nfs-kernel-server restart")
      @instance.nfs_export(@ip, @folders)
    end
  end

  context "nfs cleanup" do
    # TODO: How to test all the system calls?
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrantup-0.5.4 test/vagrant/hosts/linux_test.rb
vagrantup-0.5.3 test/vagrant/hosts/linux_test.rb
vagrant-0.5.4 test/vagrant/hosts/linux_test.rb
vagrant-0.5.3 test/vagrant/hosts/linux_test.rb