Skip to content

Commit 3093f76

Browse files
committed
Test against message property.
1 parent f80fe0f commit 3093f76

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

integrations/lfs_getobject_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"code.gitea.io/gitea/modules/setting"
1818
"code.gitea.io/gitea/routers/routes"
1919

20+
jsoniter "github.com/json-iterator/go"
2021
gzipp "github.com/klauspost/compress/gzip"
2122
"github.com/stretchr/testify/assert"
2223
)
@@ -198,7 +199,7 @@ func TestGetLFSRange(t *testing.T) {
198199
{"bytes=0-10", "123456789\n", http.StatusPartialContent},
199200
// end-range bigger than length-1 is ignored
200201
{"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},
202203
// incorrect header value cause whole header to be ignored
203204
{"bytes=-", "123456789\n", http.StatusOK},
204205
{"foobar", "123456789\n", http.StatusOK},
@@ -210,7 +211,14 @@ func TestGetLFSRange(t *testing.T) {
210211
"Range": []string{tt.in},
211212
}
212213
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+
}
214222
})
215223
}
216224
}

0 commit comments

Comments
 (0)