@@ -13,6 +13,7 @@ import (
1313 "fmt"
1414 "io"
1515 "net/http"
16+ "path"
1617 "strings"
1718 "sync"
1819 "testing"
@@ -40,8 +41,9 @@ func TestPackageArch(t *testing.T) {
4041 }
4142 rootURL := fmt .Sprintf ("/api/packages/%s/arch" , user .Name )
4243
44+ // TODO: in the future, these test packages should be build on the fly
4345 pkgs := map [string ][]byte {
44- // pkgname = test, arch = any
46+ // the zst test packages with different arch: pkgname = test
4547 "any" : unpack (`
4648KLUv/QBYXRMABmOHSbCWag6dY6d8VNtVR3rpBnWdBbkDAxM38Dj3XG3FK01TCKlWtMV9QpskYdsm
4749e6fh5gWqM8edeurYNESoIUz/RmtyQy68HVrBj1p+AIoAYABFSJh4jcDyWNQgHIKIuNgIll64S4oY
@@ -83,8 +85,10 @@ I2dkIEMjxsSOiAlJjH4HIwbTjayZJidXVxKQYH2gICOCBhK7KqMlLZ4gMCU1BapYlsTAXnywepyy
8385jMBmtEhxyCnCZdUAwYKxAxeRFVk4TCL0aYgWjt3kHTg9SjVStppI2YCSWshUEFGdmJmyCVGpnqIU
8486KNlA0hEjIOACGSLqYpXAD5SSNVT2MJRJwREAF4FRHPBlCJMSNwFguGAWDJBg+KIArkIJGNtCydUL
8587TuN1oBh/+zKkEblAsgjGqVgUwKLP+UOMOGCpAhICtg6ncFJH` ),
86- // pkgname = test2, arch = any
87- "otherXZ" : unpack (`
88+
89+ // another package to test different compression: pkgname = test2, arch = any
90+ // for example: archlinuxarm uses xz
91+ "test2.xz" : unpack (`
8892/Td6WFoAAATm1rRGBMCyBIAYIQEWAAAAAAAAABaHRszgC/8CKl0AFxNGhTWwfXmuDQEJlHgNLrkq
8993VxpJY6d9iRTt6gB4uCj0481rnYfXaUADHzOFuF3490RPrM6juPXrknqtVyuWJ5efW19BgwctN6xk
9094UiXiZaXVAWVWJWy2XHJiyYCMWBfIjUfo1ccOgwolwgFHJ64ZJjbayA3k6lYPcImuAqYL5NEVHpwl
@@ -97,7 +101,7 @@ MZDP1PBie6GqDV2GuPz+0XXmul/ds+XysG19HIkKbJ+cQKp5o7Y0tI7EHM8GhwMl7MjgpQGj5nuv
97101J/QqTPWE0nJf1PW/J9yFQVR1Xo0TJyiX8/ObwmbqUPpxRGjKlYRBvn0jbTdUAENBSn+QVcASRGFE
98102SB9OM2B8Bg4jR/oojs8Beoq7zbIblgAAAACfRtXvhmznOgABzgSAGAAAKklb4rHEZ/sCAAAAAARZ
99103Wg==` ),
100- "otherZST " : unpack (`
104+ "test2.zst " : unpack (`
101105KLUv/QRYbRMABuOHS9BSNQdQ56F+xNFoV3CijY54JYt3VqV1iUU3xmj00y2pyBOCuokbhDYpvNsj
102106ZJeCxqH+nQFpMf4Wa92okaZoF4eH6HsXXCBo+qy3Fn4AigBgAEaYrLCQEuAom6YbHyuKZAFYksqi
103107sSOFiRs0WDmlACk0CnpnaAeKiCS3BlwVkViJEbDS43lFNbLkZEmGhc305Nn4AMLGiUkBDiMTG5Vz
@@ -110,7 +114,7 @@ Y9bYrCTHtwdfPPPOYiU5fvB5FssfNN2V5EIPfg9LnM+JhtVEO8+FZw5LXA068YNPhimu9sHPQiWv
110114qc6fE9BTnxIe/LTKatab+WYu7T74uWNRxJW5W5Ux0bDLuG1ioCwjg4DvGgBcgB8cUDHJ1RQ89neE
111115wvjbNUMiIZdo5hbHgEpANwMkDnL0Jr7kVFg+0pZKjBkmklNgBH1YI8dQOAAKbr6EF5wYM80KWnAd
112116nYARrByncQ==` ),
113- "otherGZ " : unpack (`
117+ "test2.gz " : unpack (`
114118H4sIAAAAAAAAA9PzDQlydWWgKTAwMDAzMVEA0UCAThsYGBuZKRiamBmbm5qZGJqbKBgYGpobGzMo
115119GNDWWRBQWlySWAR0SlF+fgk+dYTk0T03RIB8NweEwVx71tDviIFA60O75Rtc5s+9YbxteUHzhUWi
116120HBkWDcbGcUqCukrLGi4Lv8jIqNsbXhueXW8uzTe79Lr9/TVbnl69c3wR652f21+7rnU5kmjTc/38
@@ -137,7 +141,7 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
137141
138142 for _ , group := range []string {"" , "arch" , "arch/os" , "x86_64" } {
139143 groupURL := rootURL + util .Iif (group == "" , "" , "/" + group )
140- t .Run (fmt .Sprintf ("Upload[%s]" , group ), func (t * testing.T ) {
144+ t .Run (fmt .Sprintf ("Upload[group: %s]" , group ), func (t * testing.T ) {
141145 defer tests .PrintCurrentTest (t )()
142146
143147 req := NewRequestWithBody (t , "PUT" , groupURL , bytes .NewReader (pkgs ["any" ]))
@@ -190,7 +194,7 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
190194 MakeRequest (t , req , http .StatusConflict )
191195 })
192196
193- t .Run (fmt .Sprintf ("Download[%s]" , group ), func (t * testing.T ) {
197+ t .Run (fmt .Sprintf ("Download[group: %s]" , group ), func (t * testing.T ) {
194198 defer tests .PrintCurrentTest (t )()
195199 req := NewRequest (t , "GET" , groupURL + "/x86_64/test-1.0.0-1-x86_64.pkg.tar.zst" )
196200 resp := MakeRequest (t , req , http .StatusOK )
@@ -205,7 +209,7 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
205209 MakeRequest (t , req , http .StatusNotFound )
206210 })
207211
208- t .Run (fmt .Sprintf ("SignVerify[%s]" , group ), func (t * testing.T ) {
212+ t .Run (fmt .Sprintf ("SignVerify[group: %s]" , group ), func (t * testing.T ) {
209213 defer tests .PrintCurrentTest (t )()
210214 req := NewRequest (t , "GET" , rootURL + "/repository.key" )
211215 respPub := MakeRequest (t , req , http .StatusOK )
@@ -221,7 +225,7 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
221225 }
222226 })
223227
224- t .Run (fmt .Sprintf ("RepositoryDB[%s]" , group ), func (t * testing.T ) {
228+ t .Run (fmt .Sprintf ("RepositoryDB[group: %s]" , group ), func (t * testing.T ) {
225229 defer tests .PrintCurrentTest (t )()
226230 req := NewRequest (t , "GET" , rootURL + "/repository.key" )
227231 respPub := MakeRequest (t , req , http .StatusOK )
@@ -252,10 +256,10 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
252256 }
253257 })
254258
255- t .Run (fmt .Sprintf ("Delete[%s]" , group ), func (t * testing.T ) {
259+ t .Run (fmt .Sprintf ("Delete[group: %s]" , group ), func (t * testing.T ) {
256260 defer tests .PrintCurrentTest (t )()
257261 // test data
258- req := NewRequestWithBody (t , "PUT" , groupURL , bytes .NewReader (pkgs ["otherXZ " ])).
262+ req := NewRequestWithBody (t , "PUT" , groupURL , bytes .NewReader (pkgs ["test2.xz " ])).
259263 AddBasicAuth (user .Name )
260264 MakeRequest (t , req , http .StatusCreated )
261265
@@ -294,20 +298,17 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
294298 MakeRequest (t , req , http .StatusNotFound )
295299 })
296300
297- for tp , key := range map [string ]string {
298- "GZ" : "otherGZ" ,
299- "XZ" : "otherXZ" ,
300- "ZST" : "otherZST" ,
301- } {
302- t .Run (fmt .Sprintf ("Upload%s[%s]" , tp , group ), func (t * testing.T ) {
301+ for _ , pkgFileName := range []string {"test2.gz" , "test2.xz" , "test2.zst" } {
302+ pkgExtName := path .Ext (pkgFileName )
303+ t .Run (fmt .Sprintf ("Upload[group:%s,ext:%s]" , group , pkgExtName ), func (t * testing.T ) {
303304 defer tests .PrintCurrentTest (t )()
304- req := NewRequestWithBody (t , "PUT" , groupURL , bytes .NewReader (pkgs [key ])).
305+ req := NewRequestWithBody (t , "PUT" , groupURL , bytes .NewReader (pkgs [pkgFileName ])).
305306 AddBasicAuth (user .Name )
306307 MakeRequest (t , req , http .StatusCreated )
307308
308- req = NewRequest (t , "GET" , groupURL + "/x86_64/test2-1.0.0-1-any.pkg.tar." + strings . ToLower ( tp ) )
309+ req = NewRequest (t , "GET" , groupURL + "/x86_64/test2-1.0.0-1-any.pkg.tar" + pkgExtName )
309310 resp := MakeRequest (t , req , http .StatusOK )
310- require .Equal (t , pkgs [key ], resp .Body .Bytes ())
311+ require .Equal (t , pkgs [pkgFileName ], resp .Body .Bytes ())
311312
312313 req = NewRequestWithBody (t , "DELETE" , groupURL + "/test2/1.0.0-1/any" , nil ).
313314 AddBasicAuth (user .Name )
@@ -352,7 +353,7 @@ HMhNSS1IzUsBcpJAPFAwwUXSM0u4BjoaR8EoGAWjgGQAAILFeyQADAAA
352353 require .NoError (t , err )
353354 require .Len (t , files , 1 ) // only one package: "test"
354355
355- req = NewRequestWithBody (t , "PUT" , rootURL , bytes .NewReader (pkgs ["otherXZ " ])).AddBasicAuth (user .Name )
356+ req = NewRequestWithBody (t , "PUT" , rootURL , bytes .NewReader (pkgs ["test2.xz " ])).AddBasicAuth (user .Name )
356357 MakeRequest (t , req , http .StatusCreated )
357358
358359 req = NewRequest (t , "GET" , rootURL + "/x86_64/base.db" )
0 commit comments