From f4c78b95021b229968285b64f780f87f2a4a0bd2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 29 Feb 2016 13:42:37 +0100 Subject: [PATCH] Improved file backend and delete empty directories if file got removed. --- test/unit/store_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/unit/store_test.rb b/test/unit/store_test.rb index d810c3a35..cc49f5f17 100644 --- a/test/unit/store_test.rb +++ b/test/unit/store_test.rb @@ -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 = [ {