Skip to content

Commit

Permalink
Try to avoid primary key problem in postgres
Browse files Browse the repository at this point in the history
The integration tests are being affected by
go-testfixtures/testfixtures#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.
  • Loading branch information
zeripath committed Jan 20, 2019
1 parent 2456cb6 commit 20aef08
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion integrations/lfs_getobject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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")

Expand Down

0 comments on commit 20aef08

Please sign in to comment.