Added sorting for undefined snippets on method name
Этот коммит содержится в:
родитель
4871754e06
коммит
0d1fb60ba0
4 изменённых файлов: 39 добавлений и 22 удалений
|
@ -105,17 +105,17 @@ Feature: undefined step snippets
|
||||||
When I run feature suite
|
When I run feature suite
|
||||||
And the undefined step snippets should be:
|
And the undefined step snippets should be:
|
||||||
"""
|
"""
|
||||||
func thereIsAWhichCosts(arg1 string, arg2 int) error {
|
|
||||||
return godog.ErrPending
|
|
||||||
}
|
|
||||||
|
|
||||||
func iAddTheToTheBasket(arg1 string) error {
|
func iAddTheToTheBasket(arg1 string) error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func thereIsAWhichCosts(arg1 string, arg2 int) error {
|
||||||
|
return godog.ErrPending
|
||||||
|
}
|
||||||
|
|
||||||
func FeatureContext(s *godog.Suite) {
|
func FeatureContext(s *godog.Suite) {
|
||||||
s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
|
|
||||||
s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
s.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
||||||
|
s.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -131,16 +131,16 @@ Feature: undefined step snippets
|
||||||
When I run feature suite
|
When I run feature suite
|
||||||
And the undefined step snippets should be:
|
And the undefined step snippets should be:
|
||||||
"""
|
"""
|
||||||
func whichCosts(arg1 string, arg2 int) error {
|
|
||||||
return godog.ErrPending
|
|
||||||
}
|
|
||||||
|
|
||||||
func godogs(arg1 int) error {
|
func godogs(arg1 int) error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func whichCosts(arg1 string, arg2 int) error {
|
||||||
|
return godog.ErrPending
|
||||||
|
}
|
||||||
|
|
||||||
func FeatureContext(s *godog.Suite) {
|
func FeatureContext(s *godog.Suite) {
|
||||||
s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
|
|
||||||
s.Step(`^(\d+) godogs$`, godogs)
|
s.Step(`^(\d+) godogs$`, godogs)
|
||||||
|
s.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
7
fmt.go
7
fmt.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -428,7 +429,7 @@ func (f *basefmt) snippets() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var index int
|
var index int
|
||||||
var snips []*undefinedSnippet
|
var snips []undefinedSnippet
|
||||||
// build snippets
|
// build snippets
|
||||||
for _, u := range undefinedStepResults {
|
for _, u := range undefinedStepResults {
|
||||||
steps := []string{u.step.Text}
|
steps := []string{u.step.Text}
|
||||||
|
@ -470,11 +471,13 @@ func (f *basefmt) snippets() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
snips = append(snips, &undefinedSnippet{Method: name, Expr: expr, argument: arg})
|
snips = append(snips, undefinedSnippet{Method: name, Expr: expr, argument: arg})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Sort(snippetSortByMethod(snips))
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err := undefinedSnippetsTpl.Execute(&buf, snips); err != nil {
|
if err := undefinedSnippetsTpl.Execute(&buf, snips); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -67,17 +67,17 @@ func TestProgressFormatterOutput(t *testing.T) {
|
||||||
|
|
||||||
You can implement step definitions for undefined steps with these snippets:
|
You can implement step definitions for undefined steps with these snippets:
|
||||||
|
|
||||||
func undefined() error {
|
|
||||||
return godog.ErrPending
|
|
||||||
}
|
|
||||||
|
|
||||||
func nextUndefined() error {
|
func nextUndefined() error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func undefined() error {
|
||||||
|
return godog.ErrPending
|
||||||
|
}
|
||||||
|
|
||||||
func FeatureContext(s *godog.Suite) {
|
func FeatureContext(s *godog.Suite) {
|
||||||
s.Step(` + "`^undefined$`" + `, undefined)
|
|
||||||
s.Step(` + "`^next undefined$`" + `, nextUndefined)
|
s.Step(` + "`^next undefined$`" + `, nextUndefined)
|
||||||
|
s.Step(` + "`^undefined$`" + `, undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
`
|
`
|
||||||
|
@ -237,7 +237,7 @@ func TestProgressFormatterMultistepTemplates(t *testing.T) {
|
||||||
|
|
||||||
You can implement step definitions for undefined steps with these snippets:
|
You can implement step definitions for undefined steps with these snippets:
|
||||||
|
|
||||||
func undef() error {
|
func three() error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,14 +245,14 @@ func unavailableCost(arg1 string, arg2 int) error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
func three() error {
|
func undef() error {
|
||||||
return godog.ErrPending
|
return godog.ErrPending
|
||||||
}
|
}
|
||||||
|
|
||||||
func FeatureContext(s *godog.Suite) {
|
func FeatureContext(s *godog.Suite) {
|
||||||
s.Step(` + "`^undef$`" + `, undef)
|
|
||||||
s.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost)
|
|
||||||
s.Step(` + "`^three$`" + `, three)
|
s.Step(` + "`^three$`" + `, three)
|
||||||
|
s.Step(` + "`^unavailable \"([^\"]*)\" cost (\\d+)$`" + `, unavailableCost)
|
||||||
|
s.Step(` + "`^undef$`" + `, undef)
|
||||||
}
|
}
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
|
@ -38,7 +38,7 @@ type undefinedSnippet struct {
|
||||||
argument *messages.PickleStepArgument
|
argument *messages.PickleStepArgument
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *undefinedSnippet) Args() (ret string) {
|
func (s undefinedSnippet) Args() (ret string) {
|
||||||
var (
|
var (
|
||||||
args []string
|
args []string
|
||||||
pos int
|
pos int
|
||||||
|
@ -92,3 +92,17 @@ func (s *undefinedSnippet) Args() (ret string) {
|
||||||
|
|
||||||
return strings.TrimSpace(strings.TrimRight(ret, ", ") + " " + last)
|
return strings.TrimSpace(strings.TrimRight(ret, ", ") + " " + last)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type snippetSortByMethod []undefinedSnippet
|
||||||
|
|
||||||
|
func (s snippetSortByMethod) Len() int {
|
||||||
|
return len(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s snippetSortByMethod) Swap(i, j int) {
|
||||||
|
s[i], s[j] = s[j], s[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s snippetSortByMethod) Less(i, j int) bool {
|
||||||
|
return s[i].Method < s[j].Method
|
||||||
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче