Skip to content
Permalink
Browse files

refactor: remove unused logger in func

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information...
yesnault authored and fsamin committed Aug 5, 2018
1 parent b4542bd commit 203e83c9e42cbcf45f4ef25d08f638b8c5e1bf77
Showing with 12 additions and 11 deletions.
  1. +6 −6 assertion.go
  2. +4 −3 extract.go
  3. +2 −2 process_teststep.go
@@ -39,13 +39,13 @@ type assertionsApplied struct {
}

// applyChecks apply checks on result, return true if all assertions are OK, false otherwise
func applyChecks(executorResult *ExecutorResult, tc TestCase, stepNumber int, step TestStep, defaultAssertions *StepAssertions, l Logger) assertionsApplied {
res := applyAssertions(*executorResult, tc, stepNumber, step, defaultAssertions, l)
func applyChecks(executorResult *ExecutorResult, tc TestCase, stepNumber int, step TestStep, defaultAssertions *StepAssertions) assertionsApplied {
res := applyAssertions(*executorResult, tc, stepNumber, step, defaultAssertions)
if !res.ok {
return res
}

resExtract := applyExtracts(executorResult, step, l)
resExtract := applyExtracts(executorResult, step)

res.errors = append(res.errors, resExtract.errors...)
res.failures = append(res.failures, resExtract.failures...)
@@ -54,7 +54,7 @@ func applyChecks(executorResult *ExecutorResult, tc TestCase, stepNumber int, st
return res
}

func applyAssertions(executorResult ExecutorResult, tc TestCase, stepNumber int, step TestStep, defaultAssertions *StepAssertions, l Logger) assertionsApplied {
func applyAssertions(executorResult ExecutorResult, tc TestCase, stepNumber int, step TestStep, defaultAssertions *StepAssertions) assertionsApplied {
var sa StepAssertions
var errors []Failure
var failures []Failure
@@ -76,7 +76,7 @@ func applyAssertions(executorResult ExecutorResult, tc TestCase, stepNumber int,

isOK := true
for _, assertion := range sa.Assertions {
errs, fails := check(tc, stepNumber, assertion, executorResult, l)
errs, fails := check(tc, stepNumber, assertion, executorResult)
if errs != nil {
errors = append(errors, *errs)
isOK = false
@@ -98,7 +98,7 @@ func applyAssertions(executorResult ExecutorResult, tc TestCase, stepNumber int,
return assertionsApplied{isOK, errors, failures, systemout, systemerr}
}

func check(tc TestCase, stepNumber int, assertion string, executorResult ExecutorResult, l Logger) (*Failure, *Failure) {
func check(tc TestCase, stepNumber int, assertion string, executorResult ExecutorResult) (*Failure, *Failure) {
assert := splitAssertion(assertion)
if len(assert) < 2 {
return &Failure{Value: RemoveNotPrintableChar(fmt.Sprintf("invalid assertion '%s' len:'%d'", assertion, len(assert)))}, nil
@@ -10,7 +10,7 @@ import (
)

// applyExtracts try to run extract on step, return true if all extracts are OK, false otherwise
func applyExtracts(executorResult *ExecutorResult, step TestStep, l Logger) assertionsApplied {
func applyExtracts(executorResult *ExecutorResult, step TestStep) assertionsApplied {
var se StepExtracts
var errors []Failure
var failures []Failure
@@ -31,7 +31,7 @@ func applyExtracts(executorResult *ExecutorResult, step TestStep, l Logger) asse
errors: []Failure{{Value: RemoveNotPrintableChar(fmt.Sprintf("key %s in result is not found", key))}},
}
}
errs, fails := checkExtracts(transformPattern(pattern), fmt.Sprintf("%v", e[key]), executorResult, l)
errs, fails := checkExtracts(transformPattern(pattern), fmt.Sprintf("%v", e[key]), executorResult)
if errs != nil {
errors = append(errors, *errs)
isOK = false
@@ -65,7 +65,7 @@ func transformPattern(pattern string) string {
return p
}

func checkExtracts(pattern, instring string, executorResult *ExecutorResult, l Logger) (*Failure, *Failure) {
func checkExtracts(pattern, instring string, executorResult *ExecutorResult) (*Failure, *Failure) {
r := regexp.MustCompile(pattern)
match := r.FindStringSubmatch(instring)
if match == nil {
@@ -87,6 +87,7 @@ func checkExtracts(pattern, instring string, executorResult *ExecutorResult, l L
return nil, nil
}

// RemoveNotPrintableChar removes not printable chararacter from a string
func RemoveNotPrintableChar(in string) string {
m := func(r rune) rune {
if unicode.IsPrint(r) || unicode.IsSpace(r) || unicode.IsPunct(r) {
@@ -31,9 +31,9 @@ func (v *Venom) RunTestStep(tcc TestCaseContext, e *ExecutorWrap, ts *TestSuite,
ts.Templater.Add(tc.Name, stringifyExecutorResult(result))

if h, ok := e.executor.(executorWithDefaultAssertions); ok {
assertRes = applyChecks(&result, *tc, stepNumber, step, h.GetDefaultAssertions(), l)
assertRes = applyChecks(&result, *tc, stepNumber, step, h.GetDefaultAssertions())
} else {
assertRes = applyChecks(&result, *tc, stepNumber, step, nil, l)
assertRes = applyChecks(&result, *tc, stepNumber, step, nil)
}
// add result again for extracts values
ts.Templater.Add(tc.Name, stringifyExecutorResult(result))

0 comments on commit 203e83c

Please sign in to comment.
You can’t perform that action at this time.