Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go cltf] add support for godog commandline flags #1234

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions tests/cross-language/go/decrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ func decryptedDataShouldBeEqualTo(payload string) error {
}

func TestDecryptFeatures(t *testing.T) {
opts := godog.Options{
Paths: []string{"../features/decrypt.feature"},
Format: "pretty",
TestingT: t,
}
opts := godogOptsWithDefaults(t, "../features/decrypt.feature")

status := godog.TestSuite{
Name: "decrypt",
Expand Down
33 changes: 28 additions & 5 deletions tests/cross-language/go/encrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/base64"
"encoding/json"
"flag"
"fmt"
"os"
"testing"
Expand All @@ -22,8 +23,13 @@ var (
payloadString string
encryptedPayloadString string
connection *sql.DB
godogOpts godog.Options
)

func init() {
godog.BindFlags("godog.", flag.CommandLine, &godogOpts)
}

func iHave(payload string) error {
payloadString = payload

Expand Down Expand Up @@ -146,13 +152,25 @@ func connectSQL() error {
return nil
}

func TestEncryptFeatures(t *testing.T) {
opts := godog.Options{
Paths: []string{"../features/encrypt.feature"},
Format: "pretty",
TestingT: t,
func godogOptsWithDefaults(t *testing.T, defaultPath string) (opts godog.Options) {
opts = godogOpts

opts.TestingT = t

if opts.Paths == nil {
opts.Paths = []string{defaultPath}
}

if opts.Format == "" {
opts.Format = "pretty"
}

return
}

func TestEncryptFeatures(t *testing.T) {
opts := godogOptsWithDefaults(t, "../features/encrypt.feature")

status := godog.TestSuite{
Name: "encrypt",
TestSuiteInitializer: InitializeTestSuite,
Expand All @@ -164,3 +182,8 @@ func TestEncryptFeatures(t *testing.T) {
t.Fatal("Non-zero status returned")
}
}

func TestMain(m *testing.M) {
flag.Parse()
os.Exit(m.Run())
}
2 changes: 1 addition & 1 deletion tests/cross-language/scripts/decrypt_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cd ..

cd go
echo "----------------------Decrypting data using Go--------------------------"
go test -v -test.run '^TestDecryptFeatures$'
go test -v -test.run '^TestDecryptFeatures$' -godog.paths=../features/decrypt.feature
cd ..

cd sidecar
Expand Down
2 changes: 1 addition & 1 deletion tests/cross-language/scripts/encrypt_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cd ..

cd go
echo "----------------------Encrypting payload using Go-----------------------"
go test -v -test.run '^TestEncryptFeatures$'
go test -v -test.run '^TestEncryptFeatures$' -godog.paths=../features/encrypt.feature
cd ..

cd sidecar
Expand Down