Skip to content

Commit

Permalink
Small refactor to reduce cyclomatic complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jun 20, 2019
1 parent 1d5430f commit 48f45d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools v2.1.0+incompatible h1:5USw7CrJBYKqjg9R7QlA6jzqZKEAtvW82aNmsxxGPxw=
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
25 changes: 16 additions & 9 deletions testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,25 @@ func (e *Execution) add(event TestEvent) {
e.packages[event.Package] = pkg
}
if event.PackageEvent() {
switch event.Action {
case ActionPass, ActionFail:
pkg.action = event.Action
case ActionOutput:
if isCoverageOutput(event.Output) {
pkg.coverage = strings.TrimRight(event.Output, "\n")
}
pkg.output[""] = append(pkg.output[""], event.Output)
}
e.addPackageEvent(pkg, event)
return
}
e.addTestEvent(pkg, event)
}

func (e *Execution) addPackageEvent(pkg *Package, event TestEvent) {
switch event.Action {
case ActionPass, ActionFail:
pkg.action = event.Action
case ActionOutput:
if isCoverageOutput(event.Output) {
pkg.coverage = strings.TrimRight(event.Output, "\n")
}
pkg.output[""] = append(pkg.output[""], event.Output)
}
}

func (e *Execution) addTestEvent(pkg *Package, event TestEvent) {
switch event.Action {
case ActionRun:
pkg.Total++
Expand Down

0 comments on commit 48f45d7

Please sign in to comment.