diff --git a/grpc-server/tinkerbell.go b/grpc-server/tinkerbell.go index 8d3476608..36511e308 100644 --- a/grpc-server/tinkerbell.go +++ b/grpc-server/tinkerbell.go @@ -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. diff --git a/grpc-server/tinkerbell_test.go b/grpc-server/tinkerbell_test.go index 1c994042c..2c7ce78e5 100644 --- a/grpc-server/tinkerbell_test.go +++ b/grpc-server/tinkerbell_test.go @@ -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) }) } }