From d9183b508c6db10aef158c04051012815e49c42b Mon Sep 17 00:00:00 2001 From: ahmed-mgd Date: Tue, 17 Dec 2024 14:14:45 -0500 Subject: [PATCH] Add tests for timeout and calculation error --- apps/dashboard/test/models/files_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/dashboard/test/models/files_test.rb b/apps/dashboard/test/models/files_test.rb index b38dca802..ff44e52cd 100644 --- a/apps/dashboard/test/models/files_test.rb +++ b/apps/dashboard/test/models/files_test.rb @@ -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