@@ -38,6 +38,14 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
38
38
_ , err = tw .Write ([]byte {})
39
39
Expect (err ).NotTo (HaveOccurred ())
40
40
41
+ Expect (tw .WriteHeader (& tar.Header {Name : "c-symlink" , Mode : 0755 , Size : int64 (0 ), Typeflag : tar .TypeSymlink , Linkname : "d-symlink" })).To (Succeed ())
42
+ _ , err = tw .Write ([]byte {})
43
+ Expect (err ).NotTo (HaveOccurred ())
44
+
45
+ Expect (tw .WriteHeader (& tar.Header {Name : "d-symlink" , Mode : 0755 , Size : int64 (0 ), Typeflag : tar .TypeSymlink , Linkname : "z" })).To (Succeed ())
46
+ _ , err = tw .Write ([]byte {})
47
+ Expect (err ).NotTo (HaveOccurred ())
48
+
41
49
Expect (tw .WriteHeader (& tar.Header {Name : "a-symlink" , Mode : 0755 , Size : int64 (0 ), Typeflag : tar .TypeSymlink , Linkname : "z" })).To (Succeed ())
42
50
_ , err = tw .Write ([]byte {})
43
51
Expect (err ).NotTo (HaveOccurred ())
@@ -71,6 +79,8 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
71
79
filepath .Join (tempDir , "a-symlink" ),
72
80
filepath .Join (tempDir , "b-symlink" ),
73
81
filepath .Join (tempDir , "z" ),
82
+ filepath .Join (tempDir , "d-symlink" ),
83
+ filepath .Join (tempDir , "c-symlink" ),
74
84
}))
75
85
76
86
Expect (filepath .Join (tempDir , "z" )).To (BeADirectory ())
@@ -80,6 +90,14 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
80
90
Expect (err ).NotTo (HaveOccurred ())
81
91
Expect (link ).To (Equal ("z" ))
82
92
93
+ link , err = os .Readlink (filepath .Join (tempDir , "c-symlink" ))
94
+ Expect (err ).NotTo (HaveOccurred ())
95
+ Expect (link ).To (Equal ("d-symlink" ))
96
+
97
+ link , err = os .Readlink (filepath .Join (tempDir , "d-symlink" ))
98
+ Expect (err ).NotTo (HaveOccurred ())
99
+ Expect (link ).To (Equal ("z" ))
100
+
83
101
data , err := os .ReadFile (filepath .Join (tempDir , "b-symlink" ))
84
102
Expect (err ).NotTo (HaveOccurred ())
85
103
Expect (data ).To (Equal ([]byte (filepath .Join ("z" , "x" ))))
@@ -109,6 +127,24 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
109
127
_ , err = bSymlink .Write ([]byte (filepath .Join ("a-symlink" , "x" )))
110
128
Expect (err ).NotTo (HaveOccurred ())
111
129
130
+ fileHeader = & zip.FileHeader {Name : "c-symlink" }
131
+ fileHeader .SetMode (0755 | os .ModeSymlink )
132
+
133
+ cSymlink , err := zw .CreateHeader (fileHeader )
134
+ Expect (err ).NotTo (HaveOccurred ())
135
+
136
+ _ , err = cSymlink .Write ([]byte (`d-symlink` ))
137
+ Expect (err ).NotTo (HaveOccurred ())
138
+
139
+ fileHeader = & zip.FileHeader {Name : "d-symlink" }
140
+ fileHeader .SetMode (0755 | os .ModeSymlink )
141
+
142
+ dSymlink , err := zw .CreateHeader (fileHeader )
143
+ Expect (err ).NotTo (HaveOccurred ())
144
+
145
+ _ , err = dSymlink .Write ([]byte (`z` ))
146
+ Expect (err ).NotTo (HaveOccurred ())
147
+
112
148
fileHeader = & zip.FileHeader {Name : "a-symlink" }
113
149
fileHeader .SetMode (0755 | os .ModeSymlink )
114
150
@@ -150,6 +186,8 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
150
186
filepath .Join (tempDir , "a-symlink" ),
151
187
filepath .Join (tempDir , "b-symlink" ),
152
188
filepath .Join (tempDir , "z" ),
189
+ filepath .Join (tempDir , "d-symlink" ),
190
+ filepath .Join (tempDir , "c-symlink" ),
153
191
}))
154
192
155
193
Expect (filepath .Join (tempDir , "z" )).To (BeADirectory ())
@@ -159,6 +197,14 @@ func testVacationSymlinkSorting(t *testing.T, context spec.G, it spec.S) {
159
197
Expect (err ).NotTo (HaveOccurred ())
160
198
Expect (link ).To (Equal ("z" ))
161
199
200
+ link , err = os .Readlink (filepath .Join (tempDir , "c-symlink" ))
201
+ Expect (err ).NotTo (HaveOccurred ())
202
+ Expect (link ).To (Equal ("d-symlink" ))
203
+
204
+ link , err = os .Readlink (filepath .Join (tempDir , "d-symlink" ))
205
+ Expect (err ).NotTo (HaveOccurred ())
206
+ Expect (link ).To (Equal ("z" ))
207
+
162
208
data , err := os .ReadFile (filepath .Join (tempDir , "b-symlink" ))
163
209
Expect (err ).NotTo (HaveOccurred ())
164
210
Expect (data ).To (Equal ([]byte (`x file` )))
0 commit comments