Skip to content

Commit

Permalink
fix test (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
IronPan authored and k8s-ci-robot committed Apr 12, 2019
1 parent 9a11de7 commit 05609ce
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backend/src/apiserver/storage/job_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *JobStore) buildSelectJobsQuery(selectCount bool, opts *list.Options,
// If we're not just counting, then also add select columns and perform a left join
// to get resource reference information. Also add pagination.
if !selectCount {
sqlBuilder = opts.AddPaginationToSelect(filteredSelectBuilder)
sqlBuilder = opts.AddPaginationToSelect(sqlBuilder)
sqlBuilder = s.addResourceReferences(sqlBuilder)
sqlBuilder = opts.AddSortingToSelect(sqlBuilder)
}
Expand Down
18 changes: 9 additions & 9 deletions backend/src/apiserver/storage/job_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func initializeDbAndStore() (*DB, *JobStore) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
CronScheduleEndTimeInSec: util.Int64Pointer(2),
Cron: util.StringPointer("1 * *"),
Cron: util.StringPointer("1 * *"),
},
},
Enabled: true,
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestListJobs_Pagination(t *testing.T) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
CronScheduleEndTimeInSec: util.Int64Pointer(2),
Cron: util.StringPointer("1 * *"),
Cron: util.StringPointer("1 * *"),
},
},
CreatedAtInSec: 2,
Expand Down Expand Up @@ -184,12 +184,12 @@ func TestListJobs_TotalSizeWithNoFilter(t *testing.T) {
db, jobStore := initializeDbAndStore()
defer db.Close()

opts, _ := list.NewOptions(&model.Job{}, 1, "name", nil)
opts, _ := list.NewOptions(&model.Job{}, 4, "name", nil)

// No filter
jobs, total_size, _, err := jobStore.ListJobs(&common.FilterContext{}, opts)
assert.Nil(t, err)
assert.Equal(t, 1, len(jobs))
assert.Equal(t, 2, len(jobs))
assert.Equal(t, 2, total_size)
}

Expand All @@ -198,7 +198,7 @@ func TestListJobs_TotalSizeWithFilter(t *testing.T) {
defer db.Close()

// Add a filter
opts, _ := list.NewOptions(&model.Job{}, 1, "name", &api.Filter{
opts, _ := list.NewOptions(&model.Job{}, 4, "name", &api.Filter{
Predicates: []*api.Predicate{
&api.Predicate{
Key: "name",
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestListJobs_Pagination_Descent(t *testing.T) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
CronScheduleEndTimeInSec: util.Int64Pointer(2),
Cron: util.StringPointer("1 * *"),
Cron: util.StringPointer("1 * *"),
},
},
CreatedAtInSec: 2,
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestListJobs_Pagination_LessThanPageSize(t *testing.T) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
CronScheduleEndTimeInSec: util.Int64Pointer(2),
Cron: util.StringPointer("1 * *"),
Cron: util.StringPointer("1 * *"),
},
},
CreatedAtInSec: 2,
Expand Down Expand Up @@ -747,7 +747,7 @@ func TestUpdateJob_Success(t *testing.T) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(10),
CronScheduleEndTimeInSec: util.Int64Pointer(20),
Cron: util.StringPointer("MY_CRON"),
Cron: util.StringPointer("MY_CRON"),
},
PeriodicSchedule: model.PeriodicSchedule{
PeriodicScheduleStartTimeInSec: util.Int64Pointer(30),
Expand Down Expand Up @@ -833,7 +833,7 @@ func TestUpdateJob_MostlyEmptySpec(t *testing.T) {
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: nil,
CronScheduleEndTimeInSec: nil,
Cron: util.StringPointer(""),
Cron: util.StringPointer(""),
},
PeriodicSchedule: model.PeriodicSchedule{
PeriodicScheduleStartTimeInSec: nil,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/apiserver/storage/run_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *RunStore) buildSelectRunsQuery(selectCount bool, opts *list.Options,
// If we're not just counting, then also add select columns and perform a left join
// to get resource reference information. Also add pagination.
if !selectCount {
sqlBuilder = opts.AddPaginationToSelect(filteredSelectBuilder)
sqlBuilder = opts.AddPaginationToSelect(sqlBuilder)
sqlBuilder = s.addMetricsAndResourceReferences(sqlBuilder)
sqlBuilder = opts.AddSortingToSelect(sqlBuilder)
}
Expand Down
10 changes: 5 additions & 5 deletions backend/src/apiserver/storage/run_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ func TestListRuns_TotalSizeWithNoFilter(t *testing.T) {
db, runStore := initializeRunStore()
defer db.Close()

opts, _ := list.NewOptions(&model.Run{}, 1, "", nil)
opts, _ := list.NewOptions(&model.Run{}, 4, "", nil)

// No filter
runs, total_size, _, err := runStore.ListRuns(&common.FilterContext{}, opts)
assert.Nil(t, err)
assert.Equal(t, 1, len(runs))
assert.Equal(t, 3, len(runs))
assert.Equal(t, 3, total_size)
}

Expand All @@ -186,9 +186,9 @@ func TestListRuns_TotalSizeWithFilter(t *testing.T) {
defer db.Close()

// Add a filter
opts, _ := list.NewOptions(&model.Run{}, 1, "", &api.Filter{
opts, _ := list.NewOptions(&model.Run{}, 4, "", &api.Filter{
Predicates: []*api.Predicate{
&api.Predicate{
{
Key: "name",
Op: api.Predicate_IN,
Value: &api.Predicate_StringValues{
Expand All @@ -201,7 +201,7 @@ func TestListRuns_TotalSizeWithFilter(t *testing.T) {
})
runs, total_size, _, err := runStore.ListRuns(&common.FilterContext{}, opts)
assert.Nil(t, err)
assert.Equal(t, 1, len(runs))
assert.Equal(t, 2, len(runs))
assert.Equal(t, 2, total_size)
}

Expand Down

0 comments on commit 05609ce

Please sign in to comment.