From b5c8f21ed979aee94f9f25cce31684cb6da05b06 Mon Sep 17 00:00:00 2001 From: Gabriel Crispino Date: Thu, 7 Dec 2023 10:56:10 -0300 Subject: [PATCH 1/2] test: fix tests --- _examples/api/api_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/_examples/api/api_test.go b/_examples/api/api_test.go index 2c65fe1..d255081 100644 --- a/_examples/api/api_test.go +++ b/_examples/api/api_test.go @@ -6,9 +6,10 @@ import ( "net/http/httptest" "testing" - "github.com/regen-network/gocuke" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/regen-network/gocuke" ) type suite struct { @@ -19,7 +20,12 @@ type suite struct { func TestApi(t *testing.T) { scope := &suite{TestingT: t, resp: httptest.NewRecorder()} - gocuke.NewRunner(t, scope). + run := gocuke.NewRunner(t, scope) + run.Before(func() { + scope.resp = httptest.NewRecorder() + }) + + run. Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, scope.ISendRequestTo). Step(`^the response code should be (\d+)$`, scope.TheResponseCodeShouldBe). Step(`^the response should match json:$`, scope.TheResponseShouldMatchJson). From f1538c9eac362f060fcccbb99d66310982fae5e6 Mon Sep 17 00:00:00 2001 From: Gabriel Crispino Date: Thu, 7 Dec 2023 17:45:17 -0300 Subject: [PATCH 2/2] fix: rename _examples to examples --- custom_test.go | 5 +++-- {_examples => examples}/api/api.go | 0 {_examples => examples}/api/api_test.go | 0 {_examples => examples}/api/features/version.feature | 0 {_examples => examples}/api/helpers.go | 0 {_examples => examples}/datatable/datatable.feature | 0 {_examples => examples}/datatable/datatable_test.go | 0 {_examples => examples}/simple/simple.feature | 0 simple_test.go | 4 ++-- 9 files changed, 5 insertions(+), 4 deletions(-) rename {_examples => examples}/api/api.go (100%) rename {_examples => examples}/api/api_test.go (100%) rename {_examples => examples}/api/features/version.feature (100%) rename {_examples => examples}/api/helpers.go (100%) rename {_examples => examples}/datatable/datatable.feature (100%) rename {_examples => examples}/datatable/datatable_test.go (100%) rename {_examples => examples}/simple/simple.feature (100%) diff --git a/custom_test.go b/custom_test.go index c8bd453..7594b6a 100644 --- a/custom_test.go +++ b/custom_test.go @@ -4,13 +4,14 @@ import ( "regexp" "testing" - "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" + + "github.com/regen-network/gocuke" ) func TestCustomSteps(t *testing.T) { gocuke.NewRunner(t, &customStepsSuite{}). - Path("_examples/simple/simple.feature"). + Path("examples/simple/simple.feature"). Step(`I have (\d+) cukes`, (*customStepsSuite).A). Step(regexp.MustCompile(`I eat (\d+)`), (*customStepsSuite).B). Step(`I have (\d+) left`, (*customStepsSuite).C). diff --git a/_examples/api/api.go b/examples/api/api.go similarity index 100% rename from _examples/api/api.go rename to examples/api/api.go diff --git a/_examples/api/api_test.go b/examples/api/api_test.go similarity index 100% rename from _examples/api/api_test.go rename to examples/api/api_test.go diff --git a/_examples/api/features/version.feature b/examples/api/features/version.feature similarity index 100% rename from _examples/api/features/version.feature rename to examples/api/features/version.feature diff --git a/_examples/api/helpers.go b/examples/api/helpers.go similarity index 100% rename from _examples/api/helpers.go rename to examples/api/helpers.go diff --git a/_examples/datatable/datatable.feature b/examples/datatable/datatable.feature similarity index 100% rename from _examples/datatable/datatable.feature rename to examples/datatable/datatable.feature diff --git a/_examples/datatable/datatable_test.go b/examples/datatable/datatable_test.go similarity index 100% rename from _examples/datatable/datatable_test.go rename to examples/datatable/datatable_test.go diff --git a/_examples/simple/simple.feature b/examples/simple/simple.feature similarity index 100% rename from _examples/simple/simple.feature rename to examples/simple/simple.feature diff --git a/simple_test.go b/simple_test.go index 04ce17e..e504376 100644 --- a/simple_test.go +++ b/simple_test.go @@ -7,7 +7,7 @@ import ( ) func TestSimple(t *testing.T) { - gocuke.NewRunner(t, &simpleSuite{}).Path("_examples/simple/simple.feature").Run() + gocuke.NewRunner(t, &simpleSuite{}).Path("examples/simple/simple.feature").Run() } type simpleSuite struct { @@ -31,7 +31,7 @@ func (s *simpleSuite) IHaveLeft(a int64) { // test if a struct that doesn't use a pointer and a global var func TestSimpleNonPointer(t *testing.T) { - gocuke.NewRunner(t, simpleSuiteNP{}).Path("_examples/simple/simple.feature").Run() + gocuke.NewRunner(t, simpleSuiteNP{}).Path("examples/simple/simple.feature").Run() } var globalCukes int64