From 20aef08d462c76d8c561f9d47ec40f29ed1532a7 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 15 Jan 2019 12:59:03 +0000 Subject: [PATCH] Try to avoid primary key problem in postgres The integration tests are being affected by https://github.com/go-testfixtures/testfixtures/issues/39 if we set the primary key high enough, keep a count of this and remove at the end of each test we shouldn't be affected by this. --- integrations/lfs_getobject_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/integrations/lfs_getobject_test.go b/integrations/lfs_getobject_test.go index b0a383309d761..8f01d712a3d87 100644 --- a/integrations/lfs_getobject_test.go +++ b/integrations/lfs_getobject_test.go @@ -32,10 +32,20 @@ func GenerateLFSOid(content io.Reader) (string, error) { return hex.EncodeToString(sum), nil } +var lfsID = int64(20000) + func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string { oid, err := GenerateLFSOid(bytes.NewReader(*content)) assert.NoError(t, err) - lfsMetaObject := &models.LFSMetaObject{Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID} + var lfsMetaObject *models.LFSMetaObject + + if setting.UsePostgreSQL { + lfsMetaObject = &models.LFSMetaObject{ID: lfsID, Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID} + } else { + lfsMetaObject = &models.LFSMetaObject{Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID} + } + + lfsID = lfsID + 1 lfsMetaObject, err = models.NewLFSMetaObject(lfsMetaObject) assert.NoError(t, err) contentStore := &lfs.ContentStore{BasePath: setting.LFS.ContentPath} @@ -51,6 +61,7 @@ func doLfs(t *testing.T, content *[]byte, expectGzip bool) { repo, err := models.GetRepositoryByOwnerAndName("user2", "repo1") assert.NoError(t, err) oid := storeObjectInRepo(t, repo.ID, content) + defer repo.RemoveLFSMetaObjectByOid(oid) session := loginUser(t, "user2")