Sha256: 83081c889f2d9fa7c7b41c8b5007270483d77a53e0196f0304d759de2f708056

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'minitest/autorun'
require 'osc/machete'

class TestJobDir < Minitest::Test
  def setup
    @data_root = Dir.mktmpdir
    @parent = Pathname.new(@data_root).join("containers")
  end
  
  def teardown
    FileUtils.remove_entry @data_root
  end
  
  # test and verify if we create a JobDir helper
  # with a parent directory that doesn't yet exist
  # new_jobdir returns  /path/to/parent/1
  def test_job_dir_with_missing_parent_dir
    dirhelper = OSC::Machete::JobDir.new(@parent)
    
    assert_equal [], dirhelper.jobdirs
    assert_equal [], dirhelper.targetdirs
    assert_equal @parent.join("1"), dirhelper.new_jobdir
  end

  def test_new_jobdir_succeeds_with_numbered_directories
    FileUtils.mkdir_p @parent
    
    # Initialize app directory with multiple jobs
    # and a file with a larger number
    Dir.mkdir("#{@parent}/1")
    Dir.mkdir("#{@parent}/5")
    FileUtils.touch("#{@parent}/8")
    
    # Create unique directory
    new_jobdir = OSC::Machete::JobDir.new(@parent).new_jobdir
    Dir.mkdir(new_jobdir)
    assert Dir.exists?("#{@parent}/9"), "Directory was not created: #{@parent}/9"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osc-machete-2.0.0.pre2 test/test_job_dir.rb
osc-machete-1.1.4 test/test_job_dir.rb
osc-machete-2.0.0.pre1 test/test_job_dir.rb
osc-machete-1.1.3 test/test_job_dir.rb