Skip to content

Commit

Permalink
fixing broken tests TestListBackgroundJobs and TestUpdateBackgroundJo…
Browse files Browse the repository at this point in the history
…b (Limit = 0 clause)
  • Loading branch information
AnalogJ committed Nov 7, 2023
1 parent 02706d7 commit 85c34ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion backend/pkg/database/gorm_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,11 @@ func (gr *GormRepository) ListBackgroundJobs(ctx context.Context, queryOptions m
var backgroundJobs []models.BackgroundJob
query := gr.GormClient.WithContext(ctx).
//Group("source_id"). //broken in Postgres.
Where(queryParam).Limit(queryOptions.Limit).Order("locked_time DESC")
Where(queryParam).Order("locked_time DESC")

if queryOptions.Limit > 0 {
query = query.Limit(queryOptions.Limit)
}
if queryOptions.Offset > 0 {
query = query.Offset(queryOptions.Offset)
}
Expand Down
6 changes: 3 additions & 3 deletions backend/pkg/database/gorm_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func (suite *RepositoryTestSuite) BeforeTest(suiteName, testName string) {
// AfterTest has a function to be executed right after the test finishes and receives the suite and test names as input
func (suite *RepositoryTestSuite) AfterTest(suiteName, testName string) {
suite.MockCtrl.Finish()
os.Remove(suite.TestDatabase.Name())
os.Remove(suite.TestDatabase.Name() + "-shm")
os.Remove(suite.TestDatabase.Name() + "-wal")
//os.Remove(suite.TestDatabase.Name())
//os.Remove(suite.TestDatabase.Name() + "-shm")
//os.Remove(suite.TestDatabase.Name() + "-wal")
}

// In order for 'go test' to run this suite, we need to create
Expand Down

0 comments on commit 85c34ba

Please sign in to comment.