@@ -11,30 +11,32 @@ def setup
11
11
@test_tag_file_name = "some-tag-file.txt"
12
12
@test_tag_file_text = "TAG FILE TEXT GOES HERE"
13
13
14
+ @regular_data_file_name = "something.txt"
15
+ @hidden_data_file_name = ".hidden"
16
+
14
17
# Reset test directory
15
18
FileUtils . rm_r ( @test_dir_path ) if File . exist? ( @test_dir_path )
16
19
Dir . mkdir @test_dir_path
17
- @detect_hidden_yes = true
18
- @detect_hidden_no = false
19
20
end
20
21
21
- def add_data_file
22
+ def add_data_files
22
23
File . write (
23
- File . join ( @data_dir_path , "something.txt" ) ,
24
+ File . join ( @data_dir_path , @regular_data_file_name ) ,
24
25
"Something to be preserved"
25
26
)
27
+ File . write ( File . join ( @data_dir_path , @hidden_data_file_name ) , "" )
26
28
end
27
29
28
30
def test_bag_dir
29
31
assert_equal (
30
- BagAdapter ::BagAdapter . new ( @test_dir_path , @detect_hidden_no ) . bag_dir ,
32
+ BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path ) . bag_dir ,
31
33
@test_dir_path
32
34
)
33
35
end
34
36
35
37
def test_data_dir
36
38
assert_equal (
37
- BagAdapter ::BagAdapter . new ( @test_dir_path , @detect_hidden_no ) . data_dir ,
39
+ BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path ) . data_dir ,
38
40
@data_dir_path
39
41
)
40
42
end
@@ -43,13 +45,13 @@ def test_add_bag_info
43
45
expected_text = <<~TEXT
44
46
Bag-Software-Agent: BagIt Ruby Gem (https://github.com/tipr/bagit)
45
47
Bagging-Date: 2023-12-22
46
- Payload-Oxum: 25.1
48
+ Payload-Oxum: 25.2
47
49
Some-Custom-Key: Some Value
48
50
TEXT
49
51
50
52
Date . stub :today , Date . new ( 2023 , 12 , 22 ) do
51
- bag = BagAdapter ::BagAdapter . new ( @test_dir_path , @detect_hidden_no )
52
- add_data_file
53
+ bag = BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path )
54
+ add_data_files
53
55
bag . add_bag_info ( @test_bag_info_data )
54
56
end
55
57
@@ -58,7 +60,7 @@ def test_add_bag_info
58
60
end
59
61
60
62
def test_add_tag_file
61
- bag = BagAdapter ::BagAdapter . new ( @test_dir_path , @detect_hidden_no )
63
+ bag = BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path )
62
64
bag . add_tag_file! ( tag_file_text : @test_tag_file_text , file_name : @test_tag_file_name )
63
65
64
66
expected_file_path = File . join ( @test_dir_path , @test_tag_file_name )
@@ -70,12 +72,18 @@ def test_add_tag_file
70
72
end
71
73
72
74
def test_add_manifests
73
- bag = BagAdapter ::BagAdapter . new ( @test_dir_path , @detect_hidden_no )
74
- add_data_file
75
+ bag = BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path )
76
+ add_data_files
75
77
bag . add_tag_file! ( tag_file_text : @test_tag_file_text , file_name : @test_tag_file_name )
76
78
bag . add_manifests
77
79
78
- assert File . exist? ( File . join ( @test_dir_path , "manifest-md5.txt" ) )
80
+ expected_manifest_file = File . join ( @test_dir_path , "manifest-md5.txt" )
81
+ assert File . exist? ( expected_manifest_file )
82
+ if File . exist? ( expected_manifest_file )
83
+ file_text = File . read ( expected_manifest_file )
84
+ assert file_text . include? ( @regular_data_file_name )
85
+ assert file_text . include? ( @hidden_data_file_name )
86
+ end
79
87
80
88
expected_tagmanifest_path = File . join ( @test_dir_path , "tagmanifest-md5.txt" )
81
89
assert File . exist? ( expected_tagmanifest_path )
@@ -87,4 +95,18 @@ def test_add_manifests
87
95
88
96
assert !File . exist? ( File . join ( @test_dir_path , "tagmanifest-sha1.txt" ) )
89
97
end
98
+
99
+ def test_add_manifests_when_detect_hidden_false
100
+ bag = BagAdapter ::BagAdapter . new ( target_dir : @test_dir_path , detect_hidden : false )
101
+ add_data_files
102
+ bag . add_manifests
103
+
104
+ expected_manifest_file = File . join ( @test_dir_path , "manifest-md5.txt" )
105
+ assert File . exist? ( expected_manifest_file )
106
+ if File . exist? ( expected_manifest_file )
107
+ file_text = File . read ( expected_manifest_file )
108
+ assert file_text . include? ( @regular_data_file_name )
109
+ refute file_text . include? ( @hidden_data_file_name )
110
+ end
111
+ end
90
112
end
0 commit comments