Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
Remove deprecated function
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Jul 22, 2021
1 parent f6c247b commit b1aa76a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ test-unit:

test-integration:
@echo ">> integration test"
@$(GO) test ./features/... -gcflags=-l -coverprofile=features.coverprofile -coverpkg ./... -godog -race -v
@$(GO) test ./features/... -gcflags=-l -coverprofile=features.coverprofile -coverpkg ./... -race -v --godog
9 changes: 7 additions & 2 deletions expander_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func TestChainExpanders(t *testing.T) {
"WIFE": "Jane",
}
},
func() Expander {
return func(s string) string {
return strings.ReplaceAll(s, "$DURATION", "and stay there for 3 days")
}
},
func(s string) string {
return strings.ReplaceAll(s, "$FROM", "Paris")
},
Expand All @@ -81,9 +86,9 @@ func TestChainExpanders(t *testing.T) {
_ = os.Unsetenv("DATE") // nolint:errcheck
}()

content := "On $DATE, $HUSBAND & $WIFE are going from $FROM to $TO $TRANSPORT"
content := "On $DATE, $HUSBAND & $WIFE are going from $FROM to $TO $TRANSPORT $DURATION"
actual := expand(content)
expected := "On Thursday, John & Jane are going from Paris to Berlin by bus"
expected := "On Thursday, John & Jane are going from Paris to Berlin by bus and stay there for 3 days"

assert.Equal(t, expected, actual)
}
Expand Down
10 changes: 9 additions & 1 deletion features/bootstrap/godog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/cucumber/godog"
"github.com/spf13/pflag"
"github.com/stretchr/testify/assert"

"github.com/nhatthm/expandog"
Expand All @@ -35,7 +36,14 @@ var (
//nolint:gochecknoinits
func init() {
flag.BoolVar(&runGoDogTests, "godog", false, "Set this flag is you want to run godog BDD tests")
godog.BindFlags("godog.", flag.CommandLine, &opt) // nolint: staticcheck
godog.BindCommandLineFlags("godog.", &opt)
}

func TestMain(m *testing.M) {
flag.Parse()
pflag.Parse()

os.Exit(m.Run())
}

func TestIntegration(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.2 // indirect
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
)
9 changes: 7 additions & 2 deletions step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func TestExpandStep(t *testing.T) {
"WIFE": "Jane",
}
},
func() expandog.Expander {
return func(s string) string {
return strings.ReplaceAll(s, "$DURATION", "and stay there for 3 days")
}
},
func(s string) string {
return strings.ReplaceAll(s, "$FROM", "Paris")
},
Expand All @@ -43,8 +48,8 @@ func TestExpandStep(t *testing.T) {
_ = os.Unsetenv("GREETINGS") // nolint:errcheck
}()

step := &godog.Step{Text: "$GREETINGS, $HUSBAND & $WIFE are going from $FROM to $TO $TRANSPORT"}
expected := "Hi Dave, John & Jane are going from Paris to Berlin by bus"
step := &godog.Step{Text: "$GREETINGS, $HUSBAND & $WIFE are going from $FROM to $TO $TRANSPORT $DURATION"}
expected := "Hi Dave, John & Jane are going from Paris to Berlin by bus and stay there for 3 days"

expandog.ExpandStep(step, expanders...)

Expand Down

0 comments on commit b1aa76a

Please sign in to comment.