Skip to content

Commit

Permalink
Fixes an issue with duplicate inprogress reason when scenario heading…
Browse files Browse the repository at this point in the history
… is same in different specs
  • Loading branch information
haroon-sheikh committed Jan 7, 2021
1 parent 95ad7c5 commit a73b9ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## v0.1.1

### Fixed

- Fixes an issue with duplicate inprogress reason when scenario heading is same in different specs

## v0.1.0

### Added
Expand Down
10 changes: 7 additions & 3 deletions inprogress/inprogress.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,25 @@ type ScenarioWithReason struct {
Reason string
}

func getScenarioMapKey(spec *gauge_messages.ProtoSpec, scenario *gauge_messages.ProtoScenario) string {
return fmt.Sprintf("%s_%s", spec.GetFileName(), scenario.GetScenarioHeading())
}

func GetInProgressScenariosWithReason(specs map[string]InProgressSpec) map[string]ScenarioWithReason {
inProgressScenarios := make(map[string]ScenarioWithReason, 0)
for _, spec := range specs {
if containsInProgressTags(spec.GetSpec().GetTags()) {
for _, specItem := range spec.GetSpec().GetItems() {
if specItem.GetItemType() == gauge_messages.ProtoItem_Comment && containsInProgressPrefix(specItem.GetComment().GetText()) {
for _, scenario := range spec.GetScenarios() {
key := scenario.GetScenarioHeading()
key := getScenarioMapKey(spec.GetSpec(), scenario)
inProgressScenarios[key] = ScenarioWithReason{scenario, specItem.GetComment().GetText()}
}
}
}
} else {
for _, scenario := range spec.GetScenarios() {
key := scenario.GetScenarioHeading()
key := getScenarioMapKey(spec.GetSpec(), scenario)
for _, scenItem := range scenario.GetScenarioItems() {
if scenItem.GetItemType() == gauge_messages.ProtoItem_Comment && containsInProgressPrefix(scenItem.GetComment().GetText()) {
inProgressScenarios[key] = ScenarioWithReason{scenario, scenItem.GetComment().GetText()}
Expand Down Expand Up @@ -301,7 +305,7 @@ func WriteToFile(inProgressSpecs map[string]InProgressSpec, inProgressScenariosW
if console {
logger.Infof(scenarioLine)
}
inProgressReason := inProgressScenariosWithReason[scenario.GetScenarioHeading()].Reason
inProgressReason := inProgressScenariosWithReason[getScenarioMapKey(spec.GetSpec(), scenario)].Reason
if len(strings.TrimSpace(inProgressReason)) > 0 {
reasonLine := fmt.Sprintf(" - %s", inProgressReason)
_, error = file.WriteString(reasonLine + "\n")
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id" : "inprogress",
"version" : "0.1.0",
"version" : "0.1.1",
"name" : "In-progress",
"description" : "Plugin for tracking in-progress specs/scenarios.",
"install": {
Expand Down

0 comments on commit a73b9ec

Please sign in to comment.