2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-22 09:17:18 -04:00
|
|
|
require "isolation/abstract_unit"
|
|
|
|
|
|
|
|
module ApplicationTests
|
|
|
|
module RakeTests
|
|
|
|
class TmpTest < ActiveSupport::TestCase
|
2020-12-25 17:06:11 -05:00
|
|
|
include ActiveSupport::Testing::Isolation
|
2017-06-22 09:17:18 -04:00
|
|
|
|
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
teardown_app
|
|
|
|
end
|
|
|
|
|
2021-05-28 22:33:16 -04:00
|
|
|
test "tmp:clear clear cache, socket, screenshot, and storage files" do
|
2020-12-25 17:06:11 -05:00
|
|
|
Dir.chdir(app_path) do
|
2017-06-22 09:17:18 -04:00
|
|
|
FileUtils.mkdir_p("tmp/cache")
|
|
|
|
FileUtils.touch("tmp/cache/cache_file")
|
|
|
|
|
|
|
|
FileUtils.mkdir_p("tmp/sockets")
|
|
|
|
FileUtils.touch("tmp/sockets/socket_file")
|
|
|
|
|
|
|
|
FileUtils.mkdir_p("tmp/screenshots")
|
|
|
|
FileUtils.touch("tmp/screenshots/fail.png")
|
|
|
|
|
2021-05-28 22:33:16 -04:00
|
|
|
FileUtils.mkdir_p("tmp/storage/6h/np")
|
|
|
|
FileUtils.touch("tmp/storage/6h/np/6hnp81jvgt42pcfqtlpoy8qshfb0")
|
|
|
|
|
2017-09-03 12:55:26 -04:00
|
|
|
rails "tmp:clear"
|
2017-06-22 09:17:18 -04:00
|
|
|
|
|
|
|
assert_not File.exist?("tmp/cache/cache_file")
|
|
|
|
assert_not File.exist?("tmp/sockets/socket_file")
|
|
|
|
assert_not File.exist?("tmp/screenshots/fail.png")
|
2021-05-28 22:33:16 -04:00
|
|
|
assert_not File.exist?("tmp/storage/6h/np/6hnp81jvgt42pcfqtlpoy8qshfb0")
|
2017-06-22 09:17:18 -04:00
|
|
|
end
|
|
|
|
end
|
2017-07-01 20:13:55 -04:00
|
|
|
|
|
|
|
test "tmp:clear should work if folder missing" do
|
|
|
|
FileUtils.remove_dir("#{app_path}/tmp")
|
2017-09-03 12:55:26 -04:00
|
|
|
rails "tmp:clear"
|
2017-07-01 20:13:55 -04:00
|
|
|
end
|
2017-06-22 09:17:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|