]> gitweb.michael.orlitzky.com - dead/janitor.git/blob - test/apache_conf_file_test.rb
Initial commit.
[dead/janitor.git] / test / apache_conf_file_test.rb
1 require('src/apache_conf_file')
2 require('test/unit')
3
4 class ApacheConfFileTest < Test::Unit::TestCase
5
6 def test_bad_conf_file_path_raises_error
7 assert_raise(ArgumentError) do
8 acf = ApacheConfFile.new(nil)
9 end
10
11 assert_raise(ArgumentError) do
12 acf = ApacheConfFile.new('/does/not/exist')
13 end
14
15 assert_raise(ArgumentError) do
16 # This raises a "different" error than the one above,
17 # but quit giving me empty files!
18 acf = ApacheConfFile.new('test/fixtures/empty_file.txt')
19 end
20 end
21
22
23 def test_good_conf_file_loads
24 acf = ApacheConfFile.new('test/fixtures/example.com-boring.conf')
25 # That's all..
26 end
27
28
29 def test_conf_file_with_no_directives
30 acf = ApacheConfFile.new('test/fixtures/example.com-boring.conf')
31 temp_files = acf.get_php_temporary_directory_list()
32 assert_kind_of(Array, temp_files)
33 assert_equal(0, temp_files.length)
34 end
35
36
37 def test_get_php_temporary_dirs_non_unique
38 acf = ApacheConfFile.new('test/fixtures/example.com-typical.conf')
39 # There should be two (identical) directories.
40 temp_files = acf.get_php_temporary_directory_list(false)
41 assert_equal(2, temp_files.length)
42 assert_equal(temp_files[0], temp_files[1])
43 end
44
45
46 def test_get_php_temporary_dirs_unique
47 acf = ApacheConfFile.new('test/fixtures/example.com-typical.conf')
48 # There should be just one directory, since the
49 # upload_tmp and session.save paths are identical.
50 temp_files = acf.get_php_temporary_directory_list()
51 assert_equal(1, temp_files.length)
52 assert_not_equal(0, temp_files[0].length)
53 end
54
55
56 def test_get_php_temporary_dirs_different_unique
57 acf = ApacheConfFile.new('test/fixtures/example.com-different.conf')
58 temp_files = acf.get_php_temporary_directory_list()
59 assert_equal(2, temp_files.length)
60 assert_not_equal(temp_files[0], temp_files[1])
61 end
62
63
64 def test_get_php_temporary_dirs_multi_unique
65 # Two different vhosts (one SSL), both configured
66 # with the same two (different) tmp directories.
67 acf = ApacheConfFile.new('test/fixtures/example.com-multi.conf')
68 temp_files = acf.get_php_temporary_directory_list()
69 assert_equal(2, temp_files.length)
70 assert_not_equal(temp_files[0], temp_files[1])
71 end
72
73
74 def test_get_php_temporary_dirs_multi_non_unique
75 # Two different vhosts (one SSL), both configured
76 # with the same two (different) tmp directories.
77 acf = ApacheConfFile.new('test/fixtures/example.com-multi.conf')
78 temp_files = acf.get_php_temporary_directory_list(false)
79 assert_equal(4, temp_files.length)
80 end
81
82 end