@@ -17,6 +17,7 @@ import (
17
17
"code.gitea.io/gitea/modules/setting"
18
18
"code.gitea.io/gitea/routers/routes"
19
19
20
+ jsoniter "github.com/json-iterator/go"
20
21
gzipp "github.com/klauspost/compress/gzip"
21
22
"github.com/stretchr/testify/assert"
22
23
)
@@ -198,7 +199,7 @@ func TestGetLFSRange(t *testing.T) {
198
199
{"bytes=0-10" , "123456789\n " , http .StatusPartialContent },
199
200
// end-range bigger than length-1 is ignored
200
201
{"bytes=0-11" , "123456789\n " , http .StatusPartialContent },
201
- {"bytes=11-" , "{ \" message \" : \" Requested Range Not Satisfiable\" } " , http .StatusRequestedRangeNotSatisfiable },
202
+ {"bytes=11-" , "Requested Range Not Satisfiable" , http .StatusRequestedRangeNotSatisfiable },
202
203
// incorrect header value cause whole header to be ignored
203
204
{"bytes=-" , "123456789\n " , http .StatusOK },
204
205
{"foobar" , "123456789\n " , http .StatusOK },
@@ -210,7 +211,14 @@ func TestGetLFSRange(t *testing.T) {
210
211
"Range" : []string {tt .in },
211
212
}
212
213
resp := storeAndGetLfs (t , & content , & h , tt .status )
213
- assert .Equal (t , tt .out , resp .Body .String ())
214
+ if tt .status == http .StatusPartialContent || tt .status == http .StatusOK {
215
+ assert .Equal (t , tt .out , resp .Body .String ())
216
+ } else {
217
+ var er lfs.ErrorResponse
218
+ err := jsoniter .Unmarshal (resp .Body .Bytes (), & er )
219
+ assert .NoError (t , err )
220
+ assert .Equal (t , tt .out , er .Message )
221
+ }
214
222
})
215
223
}
216
224
}
0 commit comments