Skip to content

Commit

Permalink
Improve empty string test
Browse files Browse the repository at this point in the history
Signed-off-by: Rayan Das <[email protected]>
  • Loading branch information
rayandas committed Mar 31, 2021
1 parent c25ee26 commit 1dd406a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions grpc-server/tinkerbell.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *server) GetWorkflowContextList(context context.Context, req *pb.Workflo
// GetWorkflowActions implements tinkerbell.GetWorkflowActions
func (s *server) GetWorkflowActions(context context.Context, req *pb.WorkflowActionsRequest) (*pb.WorkflowActionList, error) {
wfID := req.GetWorkflowId()
if len(wfID) == 0 {
if wfID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidWorkflowId)
}
return getWorkflowActions(context, s.db, wfID)
Expand All @@ -83,13 +83,13 @@ func (s *server) GetWorkflowActions(context context.Context, req *pb.WorkflowAct
// ReportActionStatus implements tinkerbell.ReportActionStatus
func (s *server) ReportActionStatus(context context.Context, req *pb.WorkflowActionStatus) (*pb.Empty, error) {
wfID := req.GetWorkflowId()
if len(wfID) == 0 {
if wfID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidWorkflowId)
}
if len(req.GetTaskName()) == 0 {
if req.GetTaskName() == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidTaskName)
}
if len(req.GetActionName()) == 0 {
if req.GetActionName() == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidActionName)
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func (s *server) ReportActionStatus(context context.Context, req *pb.WorkflowAct
// UpdateWorkflowData updates workflow ephemeral data
func (s *server) UpdateWorkflowData(context context.Context, req *pb.UpdateWorkflowDataRequest) (*pb.Empty, error) {
wfID := req.GetWorkflowId()
if len(wfID) == 0 {
if wfID == "" {
return &pb.Empty{}, status.Errorf(codes.InvalidArgument, errInvalidWorkflowId)
}
_, ok := workflowData[wfID]
Expand All @@ -168,7 +168,7 @@ func (s *server) UpdateWorkflowData(context context.Context, req *pb.UpdateWorkf
// GetWorkflowData gets the ephemeral data for a workflow
func (s *server) GetWorkflowData(context context.Context, req *pb.GetWorkflowDataRequest) (*pb.GetWorkflowDataResponse, error) {
wfID := req.GetWorkflowId()
if len(wfID) == 0 {
if wfID == "" {
return &pb.GetWorkflowDataResponse{Data: []byte("")}, status.Errorf(codes.InvalidArgument, errInvalidWorkflowId)
}
data, err := s.db.GetfromWfDataTable(context, req)
Expand Down Expand Up @@ -197,7 +197,7 @@ func (s *server) GetWorkflowDataVersion(context context.Context, req *pb.GetWork
}

func getWorkflowsForWorker(db db.Database, id string) ([]string, error) {
if len(id) == 0 {
if id == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidWorkerID)
}
wfs, err := db.GetWorkflowsForWorker(id)
Expand Down

0 comments on commit 1dd406a

Please sign in to comment.