Skip to content

Commit

Permalink
Return empty WorkflowContextList from GetWorkflowContextList
Browse files Browse the repository at this point in the history
Fixes #391

Signed-off-by: Steve Wills <steve@mouf.net>
  • Loading branch information
swills committed Jan 3, 2022
1 parent b18b238 commit 5a233ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
21 changes: 9 additions & 12 deletions grpc-server/tinkerbell.go
Expand Up @@ -55,20 +55,17 @@ func (s *server) GetWorkflowContextList(ctx context.Context, req *pb.WorkflowCon
return nil, err
}

if wfs != nil {
wfContexts := []*pb.WorkflowContext{}
for _, wf := range wfs {
wfContext, err := s.db.GetWorkflowContexts(ctx, wf)
if err != nil {
return nil, status.Errorf(codes.Aborted, err.Error())
}
wfContexts = append(wfContexts, wfContext)
wfContexts := []*pb.WorkflowContext{}
for _, wf := range wfs {
wfContext, err := s.db.GetWorkflowContexts(ctx, wf)
if err != nil {
return nil, status.Errorf(codes.Aborted, err.Error())
}
return &pb.WorkflowContextList{
WorkflowContexts: wfContexts,
}, nil
wfContexts = append(wfContexts, wfContext)
}
return nil, nil
return &pb.WorkflowContextList{
WorkflowContexts: wfContexts,
}, nil
}

// GetWorkflowActions implements tinkerbell.GetWorkflowActions.
Expand Down
8 changes: 3 additions & 5 deletions grpc-server/tinkerbell_test.go
Expand Up @@ -135,13 +135,11 @@ func TestGetWorkflowContextList(t *testing.T) {
assert.True(t, tc.want.expectedError)
return
}
if err == nil && res == nil {
assert.False(t, tc.want.expectedError)
return
}
assert.NoError(t, err)
assert.NotNil(t, res)
assert.Len(t, res.WorkflowContexts, 1)
assert.False(t, tc.want.expectedError)
assert.IsType(t, &pb.WorkflowContextList{}, res)
assert.IsType(t, []*pb.WorkflowContext{}, res.WorkflowContexts)
})
}
}
Expand Down

0 comments on commit 5a233ef

Please sign in to comment.