Improved file backend and delete empty directories if file got removed.
This commit is contained in:
parent
3713014079
commit
f4c78b9502
1 changed files with 27 additions and 0 deletions
|
@ -2,6 +2,33 @@
|
|||
require 'test_helper'
|
||||
|
||||
class StoreTest < ActiveSupport::TestCase
|
||||
test 'store fs - get_location' do
|
||||
sha = 'ed7002b439e9ac845f22357d822bac1444730fbdb6016d3ec9432297b9ec9f73'
|
||||
location = Store::Provider::File.get_location(sha)
|
||||
assert_equal("#{Rails.root}/storage/fs/ed70/02b4/39e9a/c845f/22357d8/22bac14/44730fbdb6016d3ec9432297b9ec9f73", location)
|
||||
end
|
||||
|
||||
test 'store fs - empty dir remove' do
|
||||
sha = 'ed7002b439e9ac845f22357d822bac1444730fbdb6016d3ec9432297b9ec9f73'
|
||||
content = 'content'
|
||||
location = Store::Provider::File.get_location(sha)
|
||||
result = Store::Provider::File.add(content, sha)
|
||||
assert(result)
|
||||
exists = File.exist?(location)
|
||||
assert(exists)
|
||||
result = Store::Provider::File.delete(sha)
|
||||
exists = File.exist?(location)
|
||||
assert(!exists)
|
||||
exists = File.exist?("#{Rails.root}/storage/fs/ed70/02b4")
|
||||
assert(!exists)
|
||||
exists = File.exist?("#{Rails.root}/storage/fs/ed70/")
|
||||
assert(!exists)
|
||||
exists = File.exist?("#{Rails.root}/storage/fs/")
|
||||
assert(exists)
|
||||
exists = File.exist?("#{Rails.root}/storage/")
|
||||
assert(exists)
|
||||
end
|
||||
|
||||
test 'store attachment' do
|
||||
files = [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue