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

Commit

Permalink
Use nhatthm/expandog
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Jul 21, 2021
1 parent 0a15db3 commit ab94cd6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
3 changes: 2 additions & 1 deletion features/bootstrap/godog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"testing"

"github.com/cucumber/godog"
"github.com/nhatthm/aferodog"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"

"github.com/nhatthm/aferodog"
)

// Used by init().
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.16

require (
github.com/cucumber/godog v0.11.0
github.com/cucumber/messages-go/v10 v10.0.3
github.com/gofrs/uuid v4.0.0+incompatible // indirect
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/nhatthm/aferoassert v0.1.5
github.com/nhatthm/aferomock v0.3.0
github.com/nhatthm/expandog v0.2.0
github.com/spf13/afero v1.6.0
github.com/stretchr/testify v1.7.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ github.com/nhatthm/aferoassert v0.1.5 h1:5BKwmRUpthkJpEPUPtcMHN37mdpFbYCECCJWhI/
github.com/nhatthm/aferoassert v0.1.5/go.mod h1:l5NAuwTqiLY2vXnNbi61wE9YkEu3L9SaTNmcRyMzn2Y=
github.com/nhatthm/aferomock v0.3.0 h1:VaQORa7jawxeTi7yAAayE8ZUo7lYp5yyDn9j3wwKJNA=
github.com/nhatthm/aferomock v0.3.0/go.mod h1:/oTcy0NDM+qQJEEOWiuiKuogilXvv/KZcdaXaP/rX3g=
github.com/nhatthm/expandog v0.2.0 h1:GDj8k9WhKhMsviq7GME+TKUc0N1f35Ai2CkWiKIv1xE=
github.com/nhatthm/expandog v0.2.0/go.mod h1:aDOzq5PpWfmfCiC0s0GKfseJWnnD/1ZaR+/3iu90bCA=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
Expand Down
23 changes: 6 additions & 17 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"sync"

"github.com/cucumber/godog"
"github.com/cucumber/messages-go/v10"
"github.com/nhatthm/aferoassert"
"github.com/nhatthm/expandog"
"github.com/spf13/afero"
)

Expand Down Expand Up @@ -120,21 +119,11 @@ func (m *Manager) expandVariables(st *godog.Step) {
cwd, err := os.Getwd()
mustNoError(err)

replacer := strings.NewReplacer(
"$TEST_DIR", m.testDir,
"$CWD", cwd,
"$WORKING_DIR", cwd,
)

st.Text = replacer.Replace(st.Text)

if st.Argument == nil {
return
}

if msg, ok := st.Argument.Message.(*messages.PickleStepArgument_DocString); ok {
msg.DocString.Content = replacer.Replace(msg.DocString.Content)
}
expandog.ExpandStep(st, expandog.Pairs{
"TEST_DIR": m.testDir,
"CWD": cwd,
"WORKING_DIR": cwd,
})
}

func (m *Manager) trackPath(fs afero.Fs, path string) (string, error) {
Expand Down

0 comments on commit ab94cd6

Please # to comment.