Class: FileCacheMapTest
- Defined in:
- lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb
Constant Summary collapse
- TestDir =
File.dirname(__FILE__)+"/file_cache_map_test/testdir"
Instance Method Summary collapse
- #setup ⇒ Object
- #test_changed_version ⇒ Object
- #test_changedcontent ⇒ Object
- #test_corruptcache ⇒ Object
- #test_nocache ⇒ Object
- #test_storeload ⇒ Object
- #test_storeload_empty ⇒ Object
- #test_storeload_postfix ⇒ Object
- #test_storeload_subdir ⇒ Object
- #test_versioninfo ⇒ Object
Instance Method Details
#setup ⇒ Object
11 12 13 14 15 16 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 11 def setup FileUtils.rm_r(Dir[TestDir+"/*"]) # * doesn't include dot files FileUtils.rm_r(Dir[TestDir+"/.cache"]) @cm = RGen::Util::FileCacheMap.new(".cache", ".test") end |
#test_changed_version ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 86 def test_changed_version keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.version_info = "123" @cm.store_data(keyFile, "valuedata") @cm.version_info = "456" reasons = [] assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons)) assert_equal [:keyfile_changed], reasons end |
#test_changedcontent ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 67 def test_changedcontent keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.store_data(keyFile, "valuedata") File.open(keyFile, "a") {|f| f.write("more data")} reasons = [] assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons)) assert_equal [:keyfile_changed], reasons end |
#test_corruptcache ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 57 def test_corruptcache keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.store_data(keyFile, "valuedata") File.open(TestDir+"/.cache/fileA.test","a") {|f| f.write("more data")} reasons = [] assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons)) assert_equal [:cachefile_corrupted], reasons end |
#test_nocache ⇒ Object
18 19 20 21 22 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 18 def test_nocache reasons = [] assert_equal(:invalid, @cm.load_data(TestDir+"/fileA", :invalidation_reasons => reasons)) assert_equal [:no_cachefile], reasons end |
#test_storeload ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 24 def test_storeload keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.store_data(keyFile, "valuedata") assert(File.exist?(TestDir+"/.cache/fileA.test")) assert_equal("valuedata", @cm.load_data(keyFile)) end |
#test_storeload_empty ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 49 def test_storeload_empty keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("")} @cm.store_data(keyFile, "valuedata") assert(File.exist?(TestDir+"/.cache/fileA.test")) assert_equal("valuedata", @cm.load_data(keyFile)) end |
#test_storeload_postfix ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 41 def test_storeload_postfix keyFile = TestDir+"/fileB.txt" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.store_data(keyFile, "valuedata") assert(File.exist?(TestDir+"/.cache/fileB.txt.test")) assert_equal("valuedata", @cm.load_data(keyFile)) end |
#test_storeload_subdir ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 32 def test_storeload_subdir keyFile = TestDir+"/subdir/fileA" FileUtils.mkdir(TestDir+"/subdir") File.open(keyFile, "w") {|f| f.write("somedata")} @cm.store_data(keyFile, "valuedata") assert(File.exist?(TestDir+"/subdir/.cache/fileA.test")) assert_equal("valuedata", @cm.load_data(keyFile)) end |
#test_versioninfo ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/puppet/vendor/rgen/test/util/file_cache_map_test.rb', line 77 def test_versioninfo keyFile = TestDir+"/fileA" File.open(keyFile, "w") {|f| f.write("somedata")} @cm.version_info = "123" @cm.store_data(keyFile, "valuedata") assert(File.exist?(TestDir+"/.cache/fileA.test")) assert_equal("valuedata", @cm.load_data(keyFile)) end |