tighten up Hub and add comments
[god.git] / test / test_conditions_disk_usage.rb
blob0e43e28e1c491bead8bfb652978a6f570b3cf1aa
1 require File.dirname(__FILE__) + '/helper'
3 class TestConditionsDiskUsage < Test::Unit::TestCase
4   # valid?
5   
6   def test_valid_should_return_false_if_no_above_given
7     c = Conditions::DiskUsage.new
8     c.mount_point = '/'
9     c.watch = stub(:name => 'foo')
10     
11     no_stdout do
12       assert_equal false, c.valid?
13     end
14   end
15   
16   def test_valid_should_return_false_if_no_mount_point_given
17     c = Conditions::DiskUsage.new
18     c.above = 90
19     c.watch = stub(:name => 'foo')
20     
21     no_stdout do
22       assert_equal false, c.valid?
23     end
24   end
25   
26   def test_valid_should_return_true_if_required_options_all_set
27     c = Conditions::DiskUsage.new
28     c.above = 90
29     c.mount_point = '/'
30     c.watch = stub(:name => 'foo')
31     
32     assert_equal true, c.valid?
33   end
34   
35   # test
36   
37   def test_test_should_return_true_if_above_limit
38     c = Conditions::DiskUsage.new
39     c.above = 90
40     c.mount_point = '/'
41     
42     c.expects(:`).returns('91')
43     
44     assert_equal true, c.test
45   end
46   
47   def test_test_should_return_false_if_below_limit
48     c = Conditions::DiskUsage.new
49     c.above = 90
50     c.mount_point = '/'
51     
52     c.expects(:`).returns('90')
53     
54     assert_equal false, c.test
55   end
56 end