GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of mojombo/god
Description: Ruby process monitor
Homepage: http://god.rubyforge.org
Clone URL: git://github.com/auser/god.git
god / test / test_conditions_disk_usage.rb
100644 56 lines (42 sloc) 1.2 kb
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
require File.dirname(__FILE__) + '/helper'
 
class TestConditionsDiskUsage < Test::Unit::TestCase
  # valid?
  
  def test_valid_should_return_false_if_no_above_given
    c = Conditions::DiskUsage.new
    c.mount_point = '/'
    c.watch = stub(:name => 'foo')
    
    no_stdout do
      assert_equal false, c.valid?
    end
  end
  
  def test_valid_should_return_false_if_no_mount_point_given
    c = Conditions::DiskUsage.new
    c.above = 90
    c.watch = stub(:name => 'foo')
    
    no_stdout do
      assert_equal false, c.valid?
    end
  end
  
  def test_valid_should_return_true_if_required_options_all_set
    c = Conditions::DiskUsage.new
    c.above = 90
    c.mount_point = '/'
    c.watch = stub(:name => 'foo')
    
    assert_equal true, c.valid?
  end
  
  # test
  
  def test_test_should_return_true_if_above_limit
    c = Conditions::DiskUsage.new
    c.above = 90
    c.mount_point = '/'
    
    c.expects(:`).returns('91')
    
    assert_equal true, c.test
  end
  
  def test_test_should_return_false_if_below_limit
    c = Conditions::DiskUsage.new
    c.above = 90
    c.mount_point = '/'
    
    c.expects(:`).returns('90')
    
    assert_equal false, c.test
  end
end