From 49eaf432f8e8ace17df02d88fc929e6d3b6d66e5 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Fri, 19 Jan 2024 11:13:16 +0800 Subject: [PATCH] fix: step type --- hrp/step.go | 3 +++ hrp/step_mobile_ui.go | 5 ++++- hrp/step_request.go | 23 ++++++++++++----------- hrp/step_shell.go | 13 ++----------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/hrp/step.go b/hrp/step.go index 8c4bf757..0c95988c 100644 --- a/hrp/step.go +++ b/hrp/step.go @@ -13,6 +13,9 @@ const ( stepTypeAndroid StepType = "android" stepTypeIOS StepType = "ios" stepTypeShell StepType = "shell" + + stepTypeSuffixExtraction StepType = "_extraction" + stepTypeSuffixValidation StepType = "_validation" ) type StepResult struct { diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index f65a9d6a..efdc0dea 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -522,7 +522,10 @@ func (s *StepMobileUIValidation) Name() string { } func (s *StepMobileUIValidation) Type() StepType { - return stepTypeIOS + if s.step.Android != nil { + return stepTypeAndroid + stepTypeSuffixValidation + } + return stepTypeIOS + stepTypeSuffixValidation } func (s *StepMobileUIValidation) Struct() *TStep { diff --git a/hrp/step_request.go b/hrp/step_request.go index 129f373f..08574fd4 100644 --- a/hrp/step_request.go +++ b/hrp/step_request.go @@ -772,7 +772,8 @@ func (s *StepRequest) IOS() *StepMobile { // Shell creates a new shell action func (s *StepRequest) Shell(content string) *StepShell { s.step.Shell = &Shell{ - String: content, + String: content, + ExpectExitCode: 0, } return &StepShell{ @@ -915,13 +916,13 @@ func (s *StepRequestExtraction) Name() string { } func (s *StepRequestExtraction) Type() StepType { - if s.step.Request != nil { - return StepType(fmt.Sprintf("request-%v", s.step.Request.Method)) - } + var stepType StepType if s.step.WebSocket != nil { - return StepType(fmt.Sprintf("websocket-%v", s.step.WebSocket.Type)) + stepType = StepType(fmt.Sprintf("websocket-%v", s.step.WebSocket.Type)) + } else { + stepType = StepType(fmt.Sprintf("request-%v", s.step.Request.Method)) } - return "extraction" + return stepType + stepTypeSuffixExtraction } func (s *StepRequestExtraction) Struct() *TStep { @@ -951,13 +952,13 @@ func (s *StepRequestValidation) Name() string { } func (s *StepRequestValidation) Type() StepType { - if s.step.Request != nil { - return StepType(fmt.Sprintf("request-%v", s.step.Request.Method)) - } + var stepType StepType if s.step.WebSocket != nil { - return StepType(fmt.Sprintf("websocket-%v", s.step.WebSocket.Type)) + stepType = StepType(fmt.Sprintf("websocket-%v", s.step.WebSocket.Type)) + } else { + stepType = StepType(fmt.Sprintf("request-%v", s.step.Request.Method)) } - return "validation" + return stepType + stepTypeSuffixValidation } func (s *StepRequestValidation) Struct() *TStep { diff --git a/hrp/step_shell.go b/hrp/step_shell.go index 5ada4cd7..de376ba9 100644 --- a/hrp/step_shell.go +++ b/hrp/step_shell.go @@ -48,20 +48,11 @@ type StepShellValidation struct { } func (s *StepShellValidation) Name() string { - if s.step.Name != "" { - return s.step.Name - } - return fmt.Sprintf("%s %s", s.step.Request.Method, s.step.Request.URL) + return s.step.Name } func (s *StepShellValidation) Type() StepType { - if s.step.Request != nil { - return StepType(fmt.Sprintf("request-%v", s.step.Request.Method)) - } - if s.step.WebSocket != nil { - return StepType(fmt.Sprintf("websocket-%v", s.step.WebSocket.Type)) - } - return "validation" + return stepTypeShell + stepTypeSuffixValidation } func (s *StepShellValidation) Struct() *TStep {