File: tmp_test.rb

package info (click to toggle)
rails 2%3A7.2.2.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 43,348 kB
  • sloc: ruby: 349,797; javascript: 30,703; yacc: 46; sql: 43; sh: 29; makefile: 27
file content (47 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

require "isolation/abstract_unit"

module ApplicationTests
  module RakeTests
    class TmpTest < ActiveSupport::TestCase
      include ActiveSupport::Testing::Isolation

      def setup
        build_app
      end

      def teardown
        teardown_app
      end

      test "tmp:clear clear cache, socket, screenshot, and storage files" do
        Dir.chdir(app_path) do
          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")

          FileUtils.mkdir_p("tmp/storage/6h/np")
          FileUtils.touch("tmp/storage/6h/np/6hnp81jvgt42pcfqtlpoy8qshfb0")

          rails "tmp:clear"

          assert_not File.exist?("tmp/cache/cache_file")
          assert_not File.exist?("tmp/sockets/socket_file")
          assert_not File.exist?("tmp/screenshots/fail.png")
          assert_not File.exist?("tmp/storage/6h/np/6hnp81jvgt42pcfqtlpoy8qshfb0")
        end
      end

      test "tmp:clear should work if folder missing" do
        FileUtils.remove_dir("#{app_path}/tmp")
        rails "tmp:clear"
      end
    end
  end
end