Sha256: 96e0a3c079e7eed9358397cd8d3875d7cd69c972faaa85fe154c7324bd57c743

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

$:.unshift(File.dirname(__FILE__)+"/../lib")

require 'test/unit'
require 'fileutils'
require 'concrete/working_set'

class WorkingSetTest < Test::Unit::TestCase

  TestDir = File.dirname(__FILE__)+"/working_set_test"
 
  def test_addremove
    ws = Concrete::WorkingSet.new(File.dirname(__FILE__))
    addTestFiles(ws)
    assert_equal ["working_set_test/file1.txt", "working_set_test/file2", "working_set_test/subdir/file3.xml"], ws.fileIdentifiers
    ws.addFile(TestDir+"/file1.txt")
    assert_equal ["working_set_test/file1.txt", "working_set_test/file2", "working_set_test/subdir/file3.xml"], ws.fileIdentifiers
    ws.removeFile(TestDir+"/file1.txt")
    assert_equal ["working_set_test/file2", "working_set_test/subdir/file3.xml"], ws.fileIdentifiers
    ws.removeFile(TestDir+"/file2")
    assert_equal ["working_set_test/subdir/file3.xml"], ws.fileIdentifiers
    ws.removeFile(TestDir+"/subdir/file3.xml")
    assert_equal [], ws.fileIdentifiers
    ws.removeFile(TestDir+"/file2")
    assert_equal [], ws.fileIdentifiers
  end

  def test_addremove_root2
    ws = Concrete::WorkingSet.new(File.dirname(__FILE__)+"/..")
    addTestFiles(ws)
    assert_equal ["test/working_set_test/file1.txt", "test/working_set_test/file2", "test/working_set_test/subdir/file3.xml"], ws.fileIdentifiers
  end

  def test_addremove_root3
    ws = Concrete::WorkingSet.new(File.dirname(__FILE__)+"/working_set_test")
    addTestFiles(ws)
    assert_equal ["file1.txt", "file2", "subdir/file3.xml"], ws.fileIdentifiers
  end
  
  def test_getFile
    ws = Concrete::WorkingSet.new(File.dirname(__FILE__))
    addTestFiles(ws)
    file1 = ws.getFile("working_set_test/file1.txt")
    assert file1.index("working_set_test/file1.txt") > 0
    assert File.exist?(file1) 
  end

  def addTestFiles(ws)
    ws.addFile(TestDir+"/file1.txt")
    ws.addFile(TestDir+"/file2")
    ws.addFile(TestDir+"/subdir/file3.xml")
  end

end
 

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
concrete-0.2.1 test/working_set_test.rb
concrete-0.2.0 test/working_set_test.rb