Skip to content

Commit

Permalink
Add tests in test_bag_adapter for check_if_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
ssciolla committed Aug 6, 2024
1 parent e8e9af0 commit 958b7c0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/test_bag_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,48 @@ def test_add_manifests_when_detect_hidden_false
refute file_text.include?(@hidden_data_file_name)
end
end

def create_bag_with_hidden_file_not_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: false)
add_data_files
bag.add_manifests
end

def create_bag_with_hidden_file_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: true)
add_data_files
bag.add_manifests
end

def test_check_if_valid_when_hidden_file_in_manifest_and_detect_hidden_true
create_bag_with_hidden_file_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: true)
result = bag.check_if_valid
assert result.is_valid
assert_nil result.error_message
end

def test_check_if_valid_when_hidden_file_not_in_manifest_and_detect_hidden_true
create_bag_with_hidden_file_not_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: true)
result = bag.check_if_valid
refute result.is_valid
assert result.error_message.length > 0
end

def test_check_if_valid_when_hidden_file_in_manifest_and_detect_hidden_false
create_bag_with_hidden_file_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: false)
result = bag.check_if_valid
refute result.is_valid
assert result.error_message.length > 0
end

def test_check_if_valid_when_hidden_file_not_in_manifest_and_detect_hidden_false
create_bag_with_hidden_file_not_in_manifest
bag = BagAdapter::BagAdapter.new(target_dir: @test_dir_path, detect_hidden: false)
result = bag.check_if_valid
assert result.is_valid
assert_nil result.error_message
end
end

0 comments on commit 958b7c0

Please sign in to comment.