Skip to content

Commit

Permalink
Add tests for timeout and calculation error
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-mgd committed Dec 17, 2024
1 parent cbbb2cf commit d9183b5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apps/dashboard/test/models/files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ class FilesTest < ActiveSupport::TestCase
end
end

test "can_download_as_zip handles directory size calculation timeout" do
Dir.mktmpdir do |dir|
Open3.stubs(:capture3).returns(["", "Timeout", exit_failure(124)])
result = PosixFile.new(dir).can_download_as_zip?
error = I18n.t('dashboard.files_directory_size_calculation_timeout')

assert_equal [false, error], result
end
end

test "can_download_as_zip handles directory size calculation error" do
Dir.mktmpdir do |dir|
Open3.stubs(:capture3).returns(["", "", exit_success])
result = PosixFile.new(dir).can_download_as_zip?
error = I18n.t('dashboard.files_directory_size_calculation_error')

assert_equal [false, error], result
end
end

test "can_download_as_zip handles files sizes of 0" do
Dir.mktmpdir do |dir|
Open3.stubs(:capture3).returns(["0 /dev
Expand Down

0 comments on commit d9183b5

Please sign in to comment.