Поправлены snippet тесты и сам более удобный вид

Этот коммит содержится в:
Softonik 2023-08-19 00:52:38 +03:00 коммит произвёл Nobody
родитель baac88ef73
коммит 0da5fc6bcb
2 изменённых файлов: 46 добавлений и 56 удалений

Просмотреть файл

@ -20,16 +20,15 @@ Feature: undefined step snippets
""" """
And the undefined step snippets should be: And the undefined step snippets should be:
""" """
func iSendRequestTo(arg1, arg2 string) { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func theResponseCodeShouldBe(arg1 int) {
}
func InitializeScenario(ctx *godog.ScenarioContext) { func iSendRequestTo(arg1, arg2 string) { }
func theResponseCodeShouldBe(arg1 int) { }
ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo) ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe) ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
}
""" """
Scenario: should generate snippets with more arguments Scenario: should generate snippets with more arguments
@ -50,20 +49,17 @@ Feature: undefined step snippets
When I run feature suite When I run feature suite
Then the undefined step snippets should be: Then the undefined step snippets should be:
""" """
func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) {
}
func theResponseBodyShouldBe(arg1 *godog.DocString) { func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) { }
} func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) { }
func theResponseBodyShouldBe(arg1 *godog.DocString) { }
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith) ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe) ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe) ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe)
}
""" """
Scenario: should handle escaped symbols Scenario: should handle escaped symbols
@ -83,16 +79,15 @@ Feature: undefined step snippets
""" """
And the undefined step snippets should be: And the undefined step snippets should be:
""" """
func iPullFromGithubcom() { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func theProjectShouldBeThere() {
}
func InitializeScenario(ctx *godog.ScenarioContext) { func iPullFromGithubcom() { }
func theProjectShouldBeThere() { }
ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom) ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom)
ctx.Step(`^the project should be there$`, theProjectShouldBeThere) ctx.Step(`^the project should be there$`, theProjectShouldBeThere)
}
""" """
Scenario: should handle string argument followed by comma Scenario: should handle string argument followed by comma
@ -107,16 +102,15 @@ 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) { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func iAddTheToTheBasket(arg1 string) {
}
func InitializeScenario(ctx *godog.ScenarioContext) { func thereIsAWhichCosts(arg1 string, arg2 int) { }
func iAddTheToTheBasket(arg1 string) { }
ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts) ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket) ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
}
""" """
Scenario: should handle arguments in the beggining or end of the step Scenario: should handle arguments in the beggining or end of the step
@ -131,16 +125,15 @@ 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) { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func godogs(arg1 int) {
}
func InitializeScenario(ctx *godog.ScenarioContext) { func whichCosts(arg1 string, arg2 int) { }
func godogs(arg1 int) { }
ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts) ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
ctx.Step(`^(\d+) godogs$`, godogs) ctx.Step(`^(\d+) godogs$`, godogs)
}
""" """
Scenario: should generate snippets in russian Scenario: should generate snippets in russian
@ -167,18 +160,15 @@ Feature: undefined step snippets
""" """
And the undefined step snippets should be: And the undefined step snippets should be:
""" """
func чтото() { func InitializeScenario(ctx *godog.ScenarioContext) {}
} // ---
func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) {
}
func получаетсяЕщёБолееЧтото() { func чтото() { }
} func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) { }
func получаетсяЕщёБолееЧтото() { }
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^что-то$`, чтото) ctx.Step(`^что-то$`, чтото)
ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam) ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam)
ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото) ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото)
}
""" """

Просмотреть файл

@ -29,8 +29,8 @@ var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetH
{{ range . }}func {{ .Method }}({{ .Args }}) { } {{ range . }}func {{ .Method }}({{ .Args }}) { }
{{end}} {{end}}{{ range . }}
{{ range . }} ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}} ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
`)) `))
type undefinedSnippet struct { type undefinedSnippet struct {