diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-10 09:27:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 09:27:50 +0800 |
commit | 719bddcd76610a63dadc8555760072957a11cf30 (patch) | |
tree | 0df26092fba7e3e21444fe493e6b349473b6b0cb /integrations/api_repo_lfs_test.go | |
parent | fb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff) | |
download | gitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz gitea-719bddcd76610a63dadc8555760072957a11cf30.zip |
Move repository model into models/repo (#17933)
* Some refactors related repository model
* Move more methods out of repository
* Move repository into models/repo
* Fix test
* Fix test
* some improvements
* Remove unnecessary function
Diffstat (limited to 'integrations/api_repo_lfs_test.go')
-rw-r--r-- | integrations/api_repo_lfs_test.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/integrations/api_repo_lfs_test.go b/integrations/api_repo_lfs_test.go index 6f3becf17b..26f7e50f5b 100644 --- a/integrations/api_repo_lfs_test.go +++ b/integrations/api_repo_lfs_test.go @@ -13,6 +13,7 @@ import ( "testing" "code.gitea.io/gitea/models" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/json" @@ -28,7 +29,7 @@ func TestAPILFSNotStarted(t *testing.T) { setting.LFS.StartServer = false user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) req := NewRequestf(t, "POST", "/%s/%s.git/info/lfs/objects/batch", user.Name, repo.Name) MakeRequest(t, req, http.StatusNotFound) @@ -48,7 +49,7 @@ func TestAPILFSMediaType(t *testing.T) { setting.LFS.StartServer = true user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) req := NewRequestf(t, "POST", "/%s/%s.git/info/lfs/objects/batch", user.Name, repo.Name) MakeRequest(t, req, http.StatusUnsupportedMediaType) @@ -56,11 +57,11 @@ func TestAPILFSMediaType(t *testing.T) { MakeRequest(t, req, http.StatusUnsupportedMediaType) } -func createLFSTestRepository(t *testing.T, name string) *models.Repository { +func createLFSTestRepository(t *testing.T, name string) *repo_model.Repository { ctx := NewAPITestContext(t, "user2", "lfs-"+name+"-repo") t.Run("CreateRepo", doAPICreateRepository(ctx, false)) - repo, err := models.GetRepositoryByOwnerAndName("user2", "lfs-"+name+"-repo") + repo, err := repo_model.GetRepositoryByOwnerAndName("user2", "lfs-"+name+"-repo") assert.NoError(t, err) return repo @@ -75,7 +76,7 @@ func TestAPILFSBatch(t *testing.T) { content := []byte("dummy1") oid := storeObjectInRepo(t, repo.ID, &content) - defer repo.RemoveLFSMetaObjectByOid(oid) + defer models.RemoveLFSMetaObjectByOid(repo.ID, oid) session := loginUser(t, "user2") @@ -259,7 +260,7 @@ func TestAPILFSBatch(t *testing.T) { content := []byte("dummy0") storeObjectInRepo(t, repo2.ID, &content) - meta, err := repo.GetLFSMetaObjectByOid(p.Oid) + meta, err := models.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.Nil(t, meta) assert.Equal(t, models.ErrLFSObjectNotExist, err) @@ -274,7 +275,7 @@ func TestAPILFSBatch(t *testing.T) { assert.Nil(t, br.Objects[0].Error) assert.Empty(t, br.Objects[0].Actions) - meta, err = repo.GetLFSMetaObjectByOid(p.Oid) + meta, err = models.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.NoError(t, err) assert.NotNil(t, meta) }) @@ -331,7 +332,7 @@ func TestAPILFSUpload(t *testing.T) { content := []byte("dummy3") oid := storeObjectInRepo(t, repo.ID, &content) - defer repo.RemoveLFSMetaObjectByOid(oid) + defer models.RemoveLFSMetaObjectByOid(repo.ID, oid) session := loginUser(t, "user2") @@ -360,7 +361,7 @@ func TestAPILFSUpload(t *testing.T) { err = contentStore.Put(p, bytes.NewReader([]byte("dummy5"))) assert.NoError(t, err) - meta, err := repo.GetLFSMetaObjectByOid(p.Oid) + meta, err := models.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.Nil(t, meta) assert.Equal(t, models.ErrLFSObjectNotExist, err) @@ -373,7 +374,7 @@ func TestAPILFSUpload(t *testing.T) { req := newRequest(t, p, "dummy5") session.MakeRequest(t, req, http.StatusOK) - meta, err = repo.GetLFSMetaObjectByOid(p.Oid) + meta, err = models.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.NoError(t, err) assert.NotNil(t, meta) }) @@ -417,7 +418,7 @@ func TestAPILFSUpload(t *testing.T) { assert.NoError(t, err) assert.True(t, exist) - meta, err := repo.GetLFSMetaObjectByOid(p.Oid) + meta, err := models.GetLFSMetaObjectByOid(repo.ID, p.Oid) assert.NoError(t, err) assert.NotNil(t, meta) }) @@ -432,7 +433,7 @@ func TestAPILFSVerify(t *testing.T) { content := []byte("dummy3") oid := storeObjectInRepo(t, repo.ID, &content) - defer repo.RemoveLFSMetaObjectByOid(oid) + defer models.RemoveLFSMetaObjectByOid(repo.ID, oid) session := loginUser(t, "user2") |