/
environment_test.rb
67 lines (55 loc) · 1.77 KB
/
environment_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'test/unit'
require 'lib/veewee'
require 'tempfile'
class TestVeeweeEnvironment < Test::Unit::TestCase
def test_environment_default_to_currentdir
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(ve.definition_path.include?(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_path => ["/tmp"]})
assert_equal(ve.definition_dir,"/tmp")
end
end