summaryrefslogtreecommitdiffstats
path: root/integrations/lfs_getobject_test.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-06-06 01:59:27 +0200
committerGitHub <noreply@github.com>2021-06-06 02:59:27 +0300
commitee5e1c4a88f2f075587bfbc39438b6d6b1c3044e (patch)
tree5953d6094edeaa0ff65209ead9cc7a3ad6d753dc /integrations/lfs_getobject_test.go
parent683cfe39ef2c03f204eb558ba6ec65c2b18b9433 (diff)
downloadgitea-ee5e1c4a88f2f075587bfbc39438b6d6b1c3044e.tar.gz
gitea-ee5e1c4a88f2f075587bfbc39438b6d6b1c3044e.zip
Rewrite of the LFS server (#15523)
* Restructured code. Moved static checks out of loop. * Restructured batch api. Add support for individual errors. * Let router decide if LFS is enabled. * Renamed methods. * Return correct status from verify handler. * Unified media type check in router. * Changed error code according to spec. * Moved checks into router. * Removed invalid v1 api methods. * Unified methods. * Display better error messages. * Added size parameter. Create meta object on upload. * Use object error on invalid size. * Skip upload if object exists. * Moved methods. * Suppress fields in response. * Changed error on accept. * Added tests. * Use ErrorResponse object. * Test against message property. * Add support for the old invalid lfs client. * Fixed the check because MinIO wraps the error. * Use individual repositories. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'integrations/lfs_getobject_test.go')
-rw-r--r--integrations/lfs_getobject_test.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/integrations/lfs_getobject_test.go b/integrations/lfs_getobject_test.go
index 789c7572a7..b7423a2dbe 100644
--- a/integrations/lfs_getobject_test.go
+++ b/integrations/lfs_getobject_test.go
@@ -17,25 +17,16 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers/routes"
+ jsoniter "github.com/json-iterator/go"
gzipp "github.com/klauspost/compress/gzip"
"github.com/stretchr/testify/assert"
)
-var lfsID = int64(20000)
-
func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string {
pointer, err := lfs.GeneratePointer(bytes.NewReader(*content))
assert.NoError(t, err)
- var lfsMetaObject *models.LFSMetaObject
- if setting.Database.UsePostgreSQL {
- lfsMetaObject = &models.LFSMetaObject{ID: lfsID, Pointer: pointer, RepositoryID: repositoryID}
- } else {
- lfsMetaObject = &models.LFSMetaObject{Pointer: pointer, RepositoryID: repositoryID}
- }
-
- lfsID++
- lfsMetaObject, err = models.NewLFSMetaObject(lfsMetaObject)
+ _, err = models.NewLFSMetaObject(&models.LFSMetaObject{Pointer: pointer, RepositoryID: repositoryID})
assert.NoError(t, err)
contentStore := lfs.NewContentStore()
exist, err := contentStore.Exists(pointer)
@@ -210,7 +201,14 @@ func TestGetLFSRange(t *testing.T) {
"Range": []string{tt.in},
}
resp := storeAndGetLfs(t, &content, &h, tt.status)
- assert.Equal(t, tt.out, resp.Body.String())
+ if tt.status == http.StatusPartialContent || tt.status == http.StatusOK {
+ assert.Equal(t, tt.out, resp.Body.String())
+ } else {
+ var er lfs.ErrorResponse
+ err := jsoniter.Unmarshal(resp.Body.Bytes(), &er)
+ assert.NoError(t, err)
+ assert.Equal(t, tt.out, er.Message)
+ }
})
}
}