Sha256: 5806842f3697516a4d914a1d8430dd9399a3af14797555e5a17501d6aee456fd

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.exist?("#{@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 test/test_job_dir.rb
osc-machete-1.2.2 test/test_job_dir.rb
osc-machete-1.2.1 test/test_job_dir.rb
osc-machete-1.2.0 test/test_job_dir.rb