Skip to content

Commit

Permalink
fix: TestGetTask
Browse files Browse the repository at this point in the history
Signed-off-by: featherchen <[email protected]>
  • Loading branch information
featherchen committed Oct 28, 2024
1 parent 09cd2e3 commit 044dd03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions flyteadmin/pkg/repositories/gormimpl/task_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (r *TaskRepo) Get(ctx context.Context, input interfaces.Identifier) (models
timer := r.metrics.GetDuration.Start()
var tx *gorm.DB
if input.Version == "" {
tx := r.db.WithContext(ctx).Where("project = ? AND domain = ? AND name = ?", input.Project, input.Domain, input.Name).Limit(1)
tx = tx.Order("version DESC")
tx = r.db.WithContext(ctx).Where(`"tasks"."project" = ? AND "tasks"."domain" = ? AND "tasks"."name" = ?`, input.Project, input.Domain, input.Name).Limit(1)
tx = tx.Order(`"tasks"."version" DESC`)
tx.Find(&task)
} else {
tx = r.db.WithContext(ctx).Where(&models.Task{
Expand Down
6 changes: 3 additions & 3 deletions flyteadmin/pkg/repositories/gormimpl/task_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestGetTask(t *testing.T) {
GlobalMock.Logging = true

GlobalMock.NewMock().WithQuery(
`SELECT * FROM "tasks" WHERE project = $1 AND domain = $2 AND name = $3 ORDER BY version DESC LIMIT 1`).
`SELECT * FROM "tasks" WHERE "tasks"."project" = $1 AND "tasks"."domain" = $2 AND "tasks"."name" = $3 ORDER BY "tasks"."version" DESC LIMIT 1`).
WithReply(tasks)
output, err = taskRepo.Get(context.Background(), interfaces.Identifier{
Project: project,
Expand All @@ -98,8 +98,8 @@ func TestGetTask(t *testing.T) {
assert.Equal(t, project, output.Project)
assert.Equal(t, domain, output.Domain)
assert.Equal(t, name, output.Name)
assert.Equal(t, "v2", output.Version)
assert.Equal(t, []byte{3, 4}, output.Closure)
assert.Equal(t, version, output.Version)
assert.Equal(t, []byte{1, 2}, output.Closure)
assert.Equal(t, pythonTestTaskType, output.Type)
}

Expand Down

0 comments on commit 044dd03

Please sign in to comment.