Skip to content

Commit 32f138b

Browse files
test(flagd): adding configuration gherkin tests (open-feature#651)
Signed-off-by: Raphael Wigoutschnigg <[email protected]>
1 parent 92ff370 commit 32f138b

File tree

9 files changed

+883
-339
lines changed

9 files changed

+883
-339
lines changed

providers/flagd/e2e/config_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//go:build e2e
2+
3+
package e2e
4+
5+
import (
6+
"flag"
7+
"github.com/open-feature/go-sdk-contrib/tests/flagd/pkg/integration"
8+
"os"
9+
"testing"
10+
11+
"github.com/cucumber/godog"
12+
)
13+
14+
// usedEnvVars list of env vars that have been set
15+
var usedEnvVars []string
16+
17+
func TestConfig(t *testing.T) {
18+
if testing.Short() {
19+
// skip e2e if testing -short
20+
t.Skip()
21+
}
22+
23+
flag.Parse()
24+
25+
name := "config.feature"
26+
27+
testSuite := godog.TestSuite{
28+
Name: name,
29+
TestSuiteInitializer: integration.InitializeConfigTestSuite(func(envVar, envVarValue string) {
30+
t.Setenv(envVar, envVarValue)
31+
usedEnvVars = append(usedEnvVars, envVar)
32+
}),
33+
ScenarioInitializer: func(ctx *godog.ScenarioContext) {
34+
for _, envVar := range usedEnvVars {
35+
err := os.Unsetenv(envVar)
36+
37+
if err != nil {
38+
t.Fatal("unsetting environment variable: non-zero status returned")
39+
}
40+
}
41+
usedEnvVars = nil
42+
integration.InitializeConfigScenario(ctx)
43+
},
44+
Options: &godog.Options{
45+
Format: "pretty",
46+
Paths: []string{"./gherkin/config.feature"},
47+
TestingT: t, // Testing instance that will run subtests.
48+
Strict: true,
49+
},
50+
}
51+
52+
if testSuite.Run() != 0 {
53+
t.Fatal("non-zero status returned, failed to run evaluation tests")
54+
}
55+
}

providers/flagd/e2e/evaluation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestETestEvaluationFlagdInRPC(t *testing.T) {
2424

2525
testSuite := godog.TestSuite{
2626
Name: name,
27-
TestSuiteInitializer: integration.InitializeTestSuite(func() openfeature.FeatureProvider {
27+
TestSuiteInitializer: integration.InitializeEvaluationTestSuite(func() openfeature.FeatureProvider {
2828
provider, err := flagd.NewProvider(flagd.WithPort(8013))
2929

3030
if err != nil {
@@ -59,7 +59,7 @@ func TestJsonEvaluatorFlagdInProcess(t *testing.T) {
5959

6060
testSuite := godog.TestSuite{
6161
Name: name,
62-
TestSuiteInitializer: integration.InitializeTestSuite(func() openfeature.FeatureProvider {
62+
TestSuiteInitializer: integration.InitializeEvaluationTestSuite(func() openfeature.FeatureProvider {
6363
provider, err := flagd.NewProvider(flagd.WithInProcessResolver(), flagd.WithPort(9090))
6464

6565
if err != nil {

providers/flagd/e2e/gherkin/config.feature

Lines changed: 300 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)