From df3ce739e8893c326cc72537dc93d0a262e633fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnblad?= Date: Sun, 7 Jun 2020 15:20:02 +0200 Subject: [PATCH] Unexported some exported properties in unexported structs --- fmt.go | 4 ++-- fmt_cucumber.go | 4 ++-- fmt_junit.go | 4 ++-- fmt_pretty.go | 6 +++--- suite.go | 18 +++++++++--------- suite_context.go | 4 ++-- suite_context_test.go | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fmt.go b/fmt.go index af4e796..610047f 100644 --- a/fmt.go +++ b/fmt.go @@ -245,7 +245,7 @@ func (f *basefmt) Pickle(p *messages.Pickle) { feature := f.features[len(f.features)-1] - pr := pickleResult{Name: p.Name, AstNodeIDs: p.AstNodeIds, time: timeNowFunc()} + pr := pickleResult{name: p.Name, astNodeIDs: p.AstNodeIds, time: timeNowFunc()} feature.pickleResults = append(feature.pickleResults, &pr) } @@ -257,7 +257,7 @@ func (f *basefmt) Feature(ft *messages.GherkinDocument, p string, c []byte) { *f.firstFeature = false - f.features = append(f.features, &feature{Path: p, GherkinDocument: ft, time: timeNowFunc()}) + f.features = append(f.features, &feature{path: p, GherkinDocument: ft, time: timeNowFunc()}) } func (f *basefmt) Passed(pickle *messages.Pickle, step *messages.Pickle_PickleStep, match *StepDefinition) { diff --git a/fmt_cucumber.go b/fmt_cucumber.go index 6fe4e19..0179881 100644 --- a/fmt_cucumber.go +++ b/fmt_cucumber.go @@ -79,7 +79,7 @@ func (f *cukefmt) buildCukeElements(pickleResults []*pickleResult) (res []cukeEl res = make([]cukeElement, len(pickleResults)) for idx, pickleResult := range pickleResults { - cukeElement := f.buildCukeElement(pickleResult.Name, pickleResult.AstNodeIDs) + cukeElement := f.buildCukeElement(pickleResult.name, pickleResult.astNodeIDs) stepStartedAt := pickleResult.startedAt() @@ -170,7 +170,7 @@ type cukeFeatureJSON struct { func buildCukeFeature(feat *feature) cukeFeatureJSON { cukeFeature := cukeFeatureJSON{ - URI: feat.Path, + URI: feat.path, ID: makeCukeID(feat.Feature.Name), Keyword: feat.Feature.Keyword, Name: feat.Feature.Name, diff --git a/fmt_junit.go b/fmt_junit.go index 8d901c0..bfd7ea9 100644 --- a/fmt_junit.go +++ b/fmt_junit.go @@ -71,7 +71,7 @@ func buildJUNITPackageSuite(suiteName string, startedAt time.Time, features []*f var testcaseNames = make(map[string]int) for _, pickleResult := range feat.pickleResults { - testcaseNames[pickleResult.Name] = testcaseNames[pickleResult.Name] + 1 + testcaseNames[pickleResult.name] = testcaseNames[pickleResult.name] + 1 } var outlineNo = make(map[string]int) @@ -79,7 +79,7 @@ func buildJUNITPackageSuite(suiteName string, startedAt time.Time, features []*f tc := junitTestCase{} tc.Time = junitTimeDuration(pickleResult.startedAt(), pickleResult.finishedAt()) - tc.Name = pickleResult.Name + tc.Name = pickleResult.name if testcaseNames[tc.Name] > 1 { outlineNo[tc.Name] = outlineNo[tc.Name] + 1 tc.Name += fmt.Sprintf(" #%d", outlineNo[tc.Name]) diff --git a/fmt_pretty.go b/fmt_pretty.go index d560d92..7123174 100644 --- a/fmt_pretty.go +++ b/fmt_pretty.go @@ -145,7 +145,7 @@ func (f *pretty) scenarioLengths(scenarioAstID string) (scenarioHeaderLength int func (f *pretty) printScenarioHeader(astScenario *messages.GherkinDocument_Feature_Scenario, spaceFilling int) { text := s(f.indent) + keywordAndName(astScenario.Keyword, astScenario.Name) - text += s(spaceFilling) + f.line(f.lastFeature().Path, astScenario.Location) + text += s(spaceFilling) + f.line(f.lastFeature().path, astScenario.Location) fmt.Fprintln(f.out, "\n"+text) } @@ -204,8 +204,8 @@ func (f *pretty) Summary() { astStep := f.findStep(fail.step.AstNodeIds[0]) stepDesc := strings.TrimSpace(astStep.Keyword) + " " + fail.step.Text - fmt.Fprintln(f.out, s(f.indent)+red(scenarioDesc)+f.line(feature.Path, astScenario.Location)) - fmt.Fprintln(f.out, s(f.indent*2)+red(stepDesc)+f.line(feature.Path, astStep.Location)) + fmt.Fprintln(f.out, s(f.indent)+red(scenarioDesc)+f.line(feature.path, astScenario.Location)) + fmt.Fprintln(f.out, s(f.indent*2)+red(stepDesc)+f.line(feature.path, astStep.Location)) fmt.Fprintln(f.out, s(f.indent*3)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.err))+"\n") } } diff --git a/suite.go b/suite.go index 3d3366e..db29cb6 100644 --- a/suite.go +++ b/suite.go @@ -27,8 +27,8 @@ type feature struct { pickleResults []*pickleResult time time.Time - Content []byte `json:"-"` - Path string `json:"path"` + content []byte + path string order int } @@ -129,8 +129,8 @@ func (s sortByName) Less(i, j int) bool { return s[i].Feature.Name < s[j].Featur func (s sortByName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } type pickleResult struct { - Name string - AstNodeIDs []string + name string + astNodeIDs []string time time.Time stepResults []*stepResult } @@ -575,7 +575,7 @@ func (s *Suite) runFeature(f *feature) { } } - s.fmt.Feature(f.GherkinDocument, f.Path, f.Content) + s.fmt.Feature(f.GherkinDocument, f.path, f.content) defer func() { if !isEmptyFeature(f.pickles) { @@ -686,8 +686,8 @@ func parseFeatureFile(path string, newIDFunc func() string) (*feature, error) { return &feature{ GherkinDocument: gherkinDocument, pickles: pickles, - Content: buf.Bytes(), - Path: path, + content: buf.Bytes(), + path: path, }, nil } @@ -765,13 +765,13 @@ func parseFeatures(filter string, paths []string) ([]*feature, error) { } for _, ft := range feats { - if _, duplicate := byPath[ft.Path]; duplicate { + if _, duplicate := byPath[ft.path]; duplicate { continue } ft.order = order order++ - byPath[ft.Path] = ft + byPath[ft.path] = ft } } diff --git a/suite_context.go b/suite_context.go index 664f445..1e28894 100644 --- a/suite_context.go +++ b/suite_context.go @@ -412,7 +412,7 @@ func (s *suiteContext) aFailingStep() error { func (s *suiteContext) aFeatureFile(path string, body *DocString) error { gd, err := gherkin.ParseGherkinDocument(strings.NewReader(body.Content), (&messages.Incrementing{}).NewId) pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - s.testedSuite.features = append(s.testedSuite.features, &feature{GherkinDocument: gd, pickles: pickles, Path: path}) + s.testedSuite.features = append(s.testedSuite.features, &feature{GherkinDocument: gd, pickles: pickles, path: path}) return err } @@ -455,7 +455,7 @@ func (s *suiteContext) iShouldHaveNumFeatureFiles(num int, files *DocString) err var actual []string for _, ft := range s.testedSuite.features { - actual = append(actual, ft.Path) + actual = append(actual, ft.path) } if len(expected) != len(actual) { diff --git a/suite_context_test.go b/suite_context_test.go index a90826a..2d18dda 100644 --- a/suite_context_test.go +++ b/suite_context_test.go @@ -374,7 +374,7 @@ func (tc *godogFeaturesScenario) aFailingStep() error { func (tc *godogFeaturesScenario) aFeatureFile(path string, body *DocString) error { gd, err := gherkin.ParseGherkinDocument(strings.NewReader(body.Content), (&messages.Incrementing{}).NewId) pickles := gherkin.Pickles(*gd, path, (&messages.Incrementing{}).NewId) - tc.testedSuite.features = append(tc.testedSuite.features, &feature{GherkinDocument: gd, pickles: pickles, Path: path}) + tc.testedSuite.features = append(tc.testedSuite.features, &feature{GherkinDocument: gd, pickles: pickles, path: path}) return err } @@ -417,7 +417,7 @@ func (tc *godogFeaturesScenario) iShouldHaveNumFeatureFiles(num int, files *DocS var actual []string for _, ft := range tc.testedSuite.features { - actual = append(actual, ft.Path) + actual = append(actual, ft.path) } if len(expected) != len(actual) {