|
22 | 22 | describe JavaBuildpack::Util::Cache::CachedFile do |
23 | 23 | include_context 'application_helper' |
24 | 24 |
|
25 | | - let(:file_cache) { described_class.new(app_dir, 'http://foo-uri/') } |
| 25 | + let(:cache_root) { app_dir + 'cache/root' } |
| 26 | + |
| 27 | + let(:file_cache) { described_class.new(app_dir, 'http://foo-uri/', true) } |
26 | 28 |
|
27 | 29 | it 'should not create any files on initialization' do |
28 | 30 | %w(cached etag last_modified).each { |extension| expect(cache_file(extension)).not_to exist } |
29 | 31 | end |
30 | 32 |
|
| 33 | + it 'should create cache_root if mutable' do |
| 34 | + expect(cache_root).not_to exist |
| 35 | + |
| 36 | + described_class.new(cache_root, 'http://foo-uri/', true) |
| 37 | + |
| 38 | + expect(cache_root).to exist |
| 39 | + end |
| 40 | + |
| 41 | + it 'should not create cache_root if immutable' do |
| 42 | + expect(cache_root).not_to exist |
| 43 | + |
| 44 | + described_class.new(cache_root, 'http://foo-uri/', false) |
| 45 | + |
| 46 | + expect(cache_root).not_to exist |
| 47 | + end |
| 48 | + |
31 | 49 | it 'should not detect cached file' do |
32 | 50 | expect(file_cache.cached?).not_to be |
33 | 51 | end |
|
62 | 80 | %w(cached etag last_modified).each { |extension| expect(cache_file(extension)).not_to exist } |
63 | 81 | end |
64 | 82 |
|
| 83 | + it 'should not destroy all files if immutable' do |
| 84 | + described_class.new(app_dir, 'http://foo-uri/', false).destroy |
| 85 | + |
| 86 | + %w(cached etag last_modified).each { |extension| expect(cache_file(extension)).to exist } |
| 87 | + end |
| 88 | + |
65 | 89 | it 'should call the block with the content of the etag file' do |
66 | 90 | expect { |b| file_cache.etag(File::RDONLY, 'test-arg', &b) }.to yield_file_with_content(/foo-etag/) |
67 | 91 | end |
|
0 commit comments