@@ -14,6 +14,7 @@ import (
14
14
func TestZipArchiver_Content (t * testing.T ) {
15
15
zipfilepath := "archive-content.zip"
16
16
archiver := NewZipArchiver (zipfilepath )
17
+ defer os .Remove (zipfilepath )
17
18
if err := archiver .ArchiveContent ([]byte ("This is some content" ), "content.txt" ); err != nil {
18
19
t .Fatalf ("unexpected error: %s" , err )
19
20
}
@@ -26,6 +27,7 @@ func TestZipArchiver_Content(t *testing.T) {
26
27
func TestZipArchiver_File (t * testing.T ) {
27
28
zipfilepath := "archive-file.zip"
28
29
archiver := NewZipArchiver (zipfilepath )
30
+ defer os .Remove (zipfilepath )
29
31
if err := archiver .ArchiveFile ("./test-fixtures/test-file.txt" ); err != nil {
30
32
t .Fatalf ("unexpected error: %s" , err )
31
33
}
@@ -48,13 +50,16 @@ func TestZipArchiver_FileMode(t *testing.T) {
48
50
49
51
stringArray := [5 ]string {"0444" , "0644" , "0666" , "0744" , "0777" }
50
52
for _ , element := range stringArray {
51
- archiver := NewZipArchiver (zipFilePath )
52
- archiver .SetOutputFileMode (element )
53
- if err := archiver .ArchiveFile (toZipPath ); err != nil {
54
- t .Fatalf ("unexpected error: %s" , err )
55
- }
53
+ func () {
54
+ archiver := NewZipArchiver (zipFilePath )
55
+ defer os .Remove (zipFilePath )
56
+ archiver .SetOutputFileMode (element )
57
+ if err := archiver .ArchiveFile (toZipPath ); err != nil {
58
+ t .Fatalf ("unexpected error: %s" , err )
59
+ }
56
60
57
- ensureFileMode (t , zipFilePath , element )
61
+ ensureFileMode (t , zipFilePath , element )
62
+ }()
58
63
}
59
64
}
60
65
@@ -72,6 +77,7 @@ func TestZipArchiver_FileModified(t *testing.T) {
72
77
}
73
78
74
79
zip ()
80
+ defer os .Remove (zipFilePath )
75
81
76
82
expectedContents , err := ioutil .ReadFile (zipFilePath )
77
83
if err != nil {
@@ -99,6 +105,7 @@ func TestZipArchiver_FileModified(t *testing.T) {
99
105
func TestZipArchiver_Dir (t * testing.T ) {
100
106
zipfilepath := "archive-dir.zip"
101
107
archiver := NewZipArchiver (zipfilepath )
108
+ defer os .Remove (zipfilepath )
102
109
if err := archiver .ArchiveDir ("./test-fixtures/test-dir" , []string {"" }); err != nil {
103
110
t .Fatalf ("unexpected error: %s" , err )
104
111
}
@@ -113,6 +120,7 @@ func TestZipArchiver_Dir(t *testing.T) {
113
120
func TestZipArchiver_Dir_Exclude (t * testing.T ) {
114
121
zipfilepath := "archive-dir.zip"
115
122
archiver := NewZipArchiver (zipfilepath )
123
+ defer os .Remove (zipfilepath )
116
124
if err := archiver .ArchiveDir ("./test-fixtures/test-dir" , []string {"file2.txt" }); err != nil {
117
125
t .Fatalf ("unexpected error: %s" , err )
118
126
}
@@ -126,6 +134,7 @@ func TestZipArchiver_Dir_Exclude(t *testing.T) {
126
134
func TestZipArchiver_Dir_Exclude_With_Directory (t * testing.T ) {
127
135
zipfilepath := "archive-dir.zip"
128
136
archiver := NewZipArchiver (zipfilepath )
137
+ defer os .Remove (zipfilepath )
129
138
if err := archiver .ArchiveDir ("./test-fixtures/" , []string {"test-dir" , "test-dir2/file2.txt" }); err != nil {
130
139
t .Fatalf ("unexpected error: %s" , err )
131
140
}
@@ -146,6 +155,7 @@ func TestZipArchiver_Multiple(t *testing.T) {
146
155
}
147
156
148
157
archiver := NewZipArchiver (zipfilepath )
158
+ defer os .Remove (zipfilepath )
149
159
if err := archiver .ArchiveMultiple (content ); err != nil {
150
160
t .Fatalf ("unexpected error: %s" , err )
151
161
}
0 commit comments