Skip to content

Commit

Permalink
Added transparent Get call when fetching latest version of workflow o…
Browse files Browse the repository at this point in the history
…bjects (flyteorg#73)

Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss authored Jun 2, 2021
1 parent 5cdc946 commit 1257f75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/ext/workflow_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func (a *AdminFetcherExtClient) FetchWorkflowLatestVersion(ctx context.Context,
if err != nil {
return nil, err
}
w := wVersions[0]
return w, nil
return a.FetchWorkflowVersion(ctx, name, wVersions[0].Id.Version, project, domain)
}

// FetchWorkflowVersion fetches particular version of workflow
Expand Down
4 changes: 4 additions & 0 deletions pkg/ext/workflow_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var (
workflowListResponse *admin.WorkflowList
workflowResponse *admin.Workflow
)

func getWorkflowFetcherSetup() {
Expand Down Expand Up @@ -80,6 +81,7 @@ func getWorkflowFetcherSetup() {
workflowListResponse = &admin.WorkflowList{
Workflows: workflows,
}
workflowResponse = workflows[0]
}

func TestFetchAllVerOfWorkflow(t *testing.T) {
Expand All @@ -106,6 +108,7 @@ func TestFetchAllVerOfWorkflowEmptyResponse(t *testing.T) {

func TestFetchWorkflowLatestVersion(t *testing.T) {
getWorkflowFetcherSetup()
adminClient.OnGetWorkflowMatch(mock.Anything, mock.Anything).Return(workflowResponse, nil)
adminClient.OnListWorkflowsMatch(mock.Anything, mock.Anything).Return(workflowListResponse, nil)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain")
assert.Nil(t, err)
Expand All @@ -115,6 +118,7 @@ func TestFetchWorkflowLatestVersionError(t *testing.T) {
workflowListResponse := &admin.WorkflowList{}
getWorkflowFetcherSetup()
adminClient.OnListWorkflowsMatch(mock.Anything, mock.Anything).Return(workflowListResponse, nil)
adminClient.OnGetWorkflowMatch(mock.Anything, mock.Anything).Return(workflowResponse, nil)
_, err := adminFetcherExt.FetchWorkflowLatestVersion(ctx, "workflowName", "project", "domain")
assert.Equal(t, fmt.Errorf("no workflow retrieved for workflowName"), err)
}

0 comments on commit 1257f75

Please sign in to comment.