-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broke out some code from massive files into new files
- Loading branch information
Showing
9 changed files
with
642 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package godog | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cucumber/messages-go/v10" | ||
) | ||
|
||
type feature struct { | ||
*messages.GherkinDocument | ||
pickles []*messages.Pickle | ||
|
||
time time.Time | ||
content []byte | ||
order int | ||
} | ||
|
||
type sortFeaturesByName []*feature | ||
|
||
func (s sortFeaturesByName) Len() int { return len(s) } | ||
func (s sortFeaturesByName) Less(i, j int) bool { return s[i].Feature.Name < s[j].Feature.Name } | ||
func (s sortFeaturesByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | ||
|
||
type sortFeaturesByOrder []*feature | ||
|
||
func (s sortFeaturesByOrder) Len() int { return len(s) } | ||
func (s sortFeaturesByOrder) Less(i, j int) bool { return s[i].order < s[j].order } | ||
func (s sortFeaturesByOrder) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | ||
|
||
func (f feature) findScenario(astScenarioID string) *messages.GherkinDocument_Feature_Scenario { | ||
for _, child := range f.GherkinDocument.Feature.Children { | ||
if sc := child.GetScenario(); sc != nil && sc.Id == astScenarioID { | ||
return sc | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (f feature) findBackground(astScenarioID string) *messages.GherkinDocument_Feature_Background { | ||
var bg *messages.GherkinDocument_Feature_Background | ||
|
||
for _, child := range f.GherkinDocument.Feature.Children { | ||
if tmp := child.GetBackground(); tmp != nil { | ||
bg = tmp | ||
} | ||
|
||
if sc := child.GetScenario(); sc != nil && sc.Id == astScenarioID { | ||
return bg | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (f feature) findExample(exampleAstID string) (*messages.GherkinDocument_Feature_Scenario_Examples, *messages.GherkinDocument_Feature_TableRow) { | ||
for _, child := range f.GherkinDocument.Feature.Children { | ||
if sc := child.GetScenario(); sc != nil { | ||
for _, example := range sc.Examples { | ||
for _, row := range example.TableBody { | ||
if row.Id == exampleAstID { | ||
return example, row | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nil, nil | ||
} | ||
|
||
func (f feature) findStep(astStepID string) *messages.GherkinDocument_Feature_Step { | ||
for _, child := range f.GherkinDocument.Feature.Children { | ||
if sc := child.GetScenario(); sc != nil { | ||
for _, step := range sc.GetSteps() { | ||
if step.Id == astStepID { | ||
return step | ||
} | ||
} | ||
} | ||
|
||
if bg := child.GetBackground(); bg != nil { | ||
for _, step := range bg.GetSteps() { | ||
if step.Id == astStepID { | ||
return step | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (f feature) startedAt() time.Time { | ||
return f.time | ||
} |
Oops, something went wrong.