Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
code review: patched up tests, added testutils function, patched up i…
Browse files Browse the repository at this point in the history
…f checks

Signed-off-by: Joe Eschen <joe@union.ai>
  • Loading branch information
squiishyy committed Sep 25, 2023
1 parent 29f7f7f commit b6bf32d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 4 additions & 0 deletions pkg/manager/impl/testutils/mock_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,7 @@ func GetWorkflowRequestInterfaceBytes() []byte {
bytes, _ := proto.Marshal(GetWorkflowRequest().Spec.Template.Interface)
return bytes
}

func GetWorkflowRequestInterface() *core.TypedInterface {
return GetWorkflowRequest().Spec.Template.Interface
}
4 changes: 2 additions & 2 deletions pkg/repositories/transformers/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func FromWorkflowModel(workflowModel models.Workflow) (admin.Workflow, error) {
}

var workflowInterface core.TypedInterface
if workflowModel.TypedInterface != nil && len(workflowModel.TypedInterface) > 0 {
if len(workflowModel.TypedInterface) > 0 {
err = proto.Unmarshal(workflowModel.TypedInterface, &workflowInterface)
if err != nil {
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, fmt.Sprintf("failed to unmarshal workflow %v inputs", workflowModel.ID))
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, fmt.Sprintf("failed to unmarshal workflow %v interface", workflowModel.ID))
}
}

Expand Down
12 changes: 3 additions & 9 deletions pkg/repositories/transformers/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,15 @@ func TestFromWorkflowModels(t *testing.T) {
Version: "version a",
}, workflowList[0].Id))

var workflowInterface0 core.TypedInterface
err = proto.Unmarshal(workflowModels[0].TypedInterface, &workflowInterface0)
workflowInterface := testutils.GetWorkflowRequestInterface()
assert.NoError(t, err)

assert.True(t, proto.Equal(&admin.WorkflowClosure{
CreatedAt: createdAtAProto,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface0,
Interface: workflowInterface,
},
},
},
Expand All @@ -157,17 +156,12 @@ func TestFromWorkflowModels(t *testing.T) {
Version: "version b",
}, workflowList[1].Id))

// Expected to be nil
var workflowInterface1 core.TypedInterface
err = proto.Unmarshal(workflowModels[1].TypedInterface, &workflowInterface1)
assert.NoError(t, err)

assert.True(t, proto.Equal(&admin.WorkflowClosure{
CreatedAt: createdAtBProto,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface1,
Interface: &core.TypedInterface{},
},
},
},
Expand Down

0 comments on commit b6bf32d

Please sign in to comment.