Class: Furnish::TestCase

Inherits:
MiniTest::Unit::TestCase
  • Object
show all
Defined in:
lib/furnish/test.rb

Overview

Furnish::TestCase is a test harness for testing things with furnish, like provisioner libraries. It is intended to be consumed by other libraries.

There are few others, such as SchedulerTestCase and RunningSchedulerTestCase which are tuned to specific scenarios, but inherit from this class.

The basic case initializes furnish and the logger in a safe way in setup, and cleans up in teardown.

If FURNISH_DEBUG is present in the environment, the output of the furnish log will be presented to the standard error. Otherwise, it is sent a log file.

Direct Known Subclasses

SchedulerTestCase

Instance Method Summary collapse

Instance Method Details

#setupObject

:nodoc:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/furnish/test.rb', line 22

def setup # :nodoc:
  @tempfiles ||= []
  file = Tempfile.new('furnish_db')
  @tempfiles.push(file)
  if ENV["FURNISH_DEBUG"]
    Furnish.logger = Furnish::Logger.new($stderr, 3)
  else
    logfile = Tempfile.new('furnish_log')
    @tempfiles.push(logfile)
    Furnish.logger = Furnish::Logger.new(logfile, 3)
  end
  Furnish.init(file.path)
  return file
end

#teardownObject

:nodoc:



37
38
39
40
41
42
43
44
45
46
# File 'lib/furnish/test.rb', line 37

def teardown # :nodoc:
  unless ENV["FURNISH_DEBUG"]
    Furnish.logger.close
  end

  Furnish.shutdown
  @tempfiles.each do |file|
    file.unlink
  end
end