Этот коммит содержится в:
Iaroslav Ciupin 2024-04-08 15:08:21 +03:00 коммит произвёл GitHub
родитель 153db4eacb
коммит da57dd0766
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 29 добавлений и 31 удалений

Просмотреть файл

@ -31,8 +31,20 @@ type PickleStepResult struct {
} }
// NewStepResult ... // NewStepResult ...
func NewStepResult(pickleID, pickleStepID string, match *StepDefinition) PickleStepResult { func NewStepResult(
return PickleStepResult{FinishedAt: utils.TimeNowFunc(), PickleID: pickleID, PickleStepID: pickleStepID, Def: match} status StepResultStatus,
pickleID, pickleStepID string,
match *StepDefinition,
err error,
) PickleStepResult {
return PickleStepResult{
Status: status,
FinishedAt: utils.TimeNowFunc(),
Err: err,
PickleID: pickleID,
PickleStepID: pickleStepID,
Def: match,
}
} }
// StepResultStatus ... // StepResultStatus ...

Просмотреть файл

@ -77,13 +77,10 @@ func (s *suite) matchStep(step *messages.PickleStep) *models.StepDefinition {
} }
func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scenarioErr error, isFirst, isLast bool) (rctx context.Context, err error) { func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scenarioErr error, isFirst, isLast bool) (rctx context.Context, err error) {
var ( var match *models.StepDefinition
match *models.StepDefinition
sr = models.NewStepResult(pickle.Id, step.Id, match)
)
rctx = ctx rctx = ctx
sr.Status = StepUndefined status := StepUndefined
// user multistep definitions may panic // user multistep definitions may panic
defer func() { defer func() {
@ -105,19 +102,19 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
switch { switch {
case errors.Is(err, ErrPending): case errors.Is(err, ErrPending):
sr.Status = StepPending status = StepPending
case errors.Is(err, ErrSkip), err == nil && scenarioErr != nil: case errors.Is(err, ErrSkip), err == nil && scenarioErr != nil:
sr.Status = StepSkipped status = StepSkipped
case errors.Is(err, ErrUndefined): case errors.Is(err, ErrUndefined):
sr.Status = StepUndefined status = StepUndefined
case err != nil: case err != nil:
sr.Status = StepFailed status = StepFailed
case err == nil && scenarioErr == nil: case err == nil && scenarioErr == nil:
sr.Status = StepPassed status = StepPassed
} }
// Run after step handlers. // Run after step handlers.
rctx, err = s.runAfterStepHooks(ctx, step, sr.Status, err) rctx, err = s.runAfterStepHooks(ctx, step, status, err)
shouldFail := s.shouldFail(err) shouldFail := s.shouldFail(err)
@ -132,25 +129,20 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
switch { switch {
case err == nil: case err == nil:
sr.Status = models.Passed sr := models.NewStepResult(models.Passed, pickle.Id, step.Id, match, nil)
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Passed(pickle, step, match.GetInternalStepDefinition()) s.fmt.Passed(pickle, step, match.GetInternalStepDefinition())
case errors.Is(err, ErrPending): case errors.Is(err, ErrPending):
sr.Status = models.Pending sr := models.NewStepResult(models.Pending, pickle.Id, step.Id, match, nil)
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Pending(pickle, step, match.GetInternalStepDefinition()) s.fmt.Pending(pickle, step, match.GetInternalStepDefinition())
case errors.Is(err, ErrSkip): case errors.Is(err, ErrSkip):
sr.Status = models.Skipped sr := models.NewStepResult(models.Skipped, pickle.Id, step.Id, match, nil)
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Skipped(pickle, step, match.GetInternalStepDefinition()) s.fmt.Skipped(pickle, step, match.GetInternalStepDefinition())
default: default:
sr.Status = models.Failed sr := models.NewStepResult(models.Failed, pickle.Id, step.Id, match, err)
sr.Err = err
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Failed(pickle, step, match.GetInternalStepDefinition(), err) s.fmt.Failed(pickle, step, match.GetInternalStepDefinition(), err)
} }
}() }()
@ -165,14 +157,11 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
match = s.matchStep(step) match = s.matchStep(step)
s.storage.MustInsertStepDefintionMatch(step.AstNodeIds[0], match) s.storage.MustInsertStepDefintionMatch(step.AstNodeIds[0], match)
sr.Def = match
s.fmt.Defined(pickle, step, match.GetInternalStepDefinition()) s.fmt.Defined(pickle, step, match.GetInternalStepDefinition())
if err != nil { if err != nil {
sr = models.NewStepResult(pickle.Id, step.Id, match) sr := models.NewStepResult(models.Failed, pickle.Id, step.Id, match, nil)
sr.Status = models.Failed
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
return ctx, err return ctx, err
} }
@ -191,11 +180,9 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
Nested: match.Nested, Nested: match.Nested,
Undefined: undef, Undefined: undef,
} }
sr.Def = match
} }
sr = models.NewStepResult(pickle.Id, step.Id, match) sr := models.NewStepResult(models.Undefined, pickle.Id, step.Id, match, nil)
sr.Status = models.Undefined
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Undefined(pickle, step, match.GetInternalStepDefinition()) s.fmt.Undefined(pickle, step, match.GetInternalStepDefinition())
@ -203,8 +190,7 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
} }
if scenarioErr != nil { if scenarioErr != nil {
sr = models.NewStepResult(pickle.Id, step.Id, match) sr := models.NewStepResult(models.Skipped, pickle.Id, step.Id, match, nil)
sr.Status = models.Skipped
s.storage.MustInsertPickleStepResult(sr) s.storage.MustInsertPickleStepResult(sr)
s.fmt.Skipped(pickle, step, match.GetInternalStepDefinition()) s.fmt.Skipped(pickle, step, match.GetInternalStepDefinition())