Sha256: 5e097bb17a6649b6bfde28aa5de94db4152ecb752d171c374c26a0c437600544

Contents?: true

Size: 1.84 KB

Versions: 16

Compression:

Stored size: 1.84 KB

Contents

require 'test/unit'
require 'veewee'
require 'tempfile'

class TestVeeweeEnvironment < Test::Unit::TestCase
  def test_environment_default_to_currentdir
    # unset the VEEWEE_DIR environment which overwrites cwd
    ENV['VEEWEE_DIR'] = nil
    tempdir = Dir.mktmpdir
    Dir.chdir(tempdir)
    tempdir=Dir.pwd
    begin
      ve=Veewee::Environment.new()
      assert_equal(ve.cwd,tempdir)
    ensure
      FileUtils.remove_entry_secure tempdir
    end

  end

  # If a cwd is passed, it take precendence over currentdir
  def test_environment_override_environmentdir

    # Create a temp directory to simulate a currentdir
    tempdir = Dir.mktmpdir
    Dir.chdir(tempdir)
    tempdir=Dir.pwd
    # Now change to another dir
    Dir.chdir("/tmp")
    begin
      ve=Veewee::Environment.new({:cwd => tempdir})
      assert_equal(ve.cwd,tempdir)
    ensure
      FileUtils.remove_entry_secure tempdir
    end

  end

  # parent of isodir or definitiondir not writeable should raise an error
  def test_environment_parentdir_should_be_writeable
  end

  # definition_dir , iso_dir by default are relative to the environmentdir
  def test_environment_iso_dir_relative_to_environmentdir

    # Create a temp directory to simulate a currentdir
    tempdir = Dir.mktmpdir
    Dir.chdir(tempdir)
    tempdir=Dir.pwd
    begin
      ve=Veewee::Environment.new({:cwd => tempdir})
      assert_equal(ve.definition_dir,File.join(tempdir,"definitions"))
      assert_equal(ve.iso_dir,File.join(tempdir,"iso"))
    ensure
      FileUtils.remove_entry_secure tempdir
    end

  end

  # definition_dir , iso_dir  by default are relative to the environmentdir
  def test_environment_definition_dir_relative_to_environmentdir
    # Goto top dir , to make pwd another dir
    Dir.chdir("/")
    ve=Veewee::Environment.new({:definition_dir => "/tmp"})
    assert_equal(ve.definition_dir,"/tmp")
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
veewee-0.5.0.alpha4 test/environment_test.rb
veewee-0.5.0.alpha3 test/environment_test.rb
veewee-0.5.0.alpha2 test/environment_test.rb
veewee-0.5.0.alpha1 test/environment_test.rb
veewee-0.4.5.1 test/environment_test.rb
veewee-0.4.5 test/environment_test.rb
veewee-0.4.5.pre1 test/environment_test.rb
veewee-0.4.4 test/environment_test.rb
veewee-0.4.3 test/environment_test.rb
veewee-0.4.2 test/environment_test.rb
veewee-0.4.1 test/environment_test.rb
veewee-0.4.0 test/environment_test.rb
veewee-0.3.12 test/environment_test.rb
veewee-0.3.11 test/environment_test.rb
veewee-0.3.10 test/environment_test.rb
veewee-0.3.9 test/environment_test.rb