|
| 1 | +package io.github.sideshowcoder.dropwizard_openfeature; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 5 | + |
| 6 | +import org.junit.jupiter.api.Test; |
| 7 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 8 | + |
| 9 | +import com.codahale.metrics.health.HealthCheck; |
| 10 | + |
| 11 | +import dev.openfeature.sdk.OpenFeatureAPI; |
| 12 | +import dev.openfeature.sdk.Client; |
| 13 | +import io.dropwizard.testing.ResourceHelpers; |
| 14 | +import io.dropwizard.testing.junit5.DropwizardAppExtension; |
| 15 | +import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; |
| 16 | +import io.github.sideshowcoder.dropwizard_openfeature.helpers.App; |
| 17 | +import io.github.sideshowcoder.dropwizard_openfeature.helpers.Config; |
| 18 | + |
| 19 | +@ExtendWith(DropwizardExtensionsSupport.class) |
| 20 | +public class OpenFeatureBundleGoFeatureFlagProviderTest { |
| 21 | + |
| 22 | + // TODO start the gofeatureflag/go-feature-flag:latest docker image which is the relay proxy to interact with the provider https://gofeatureflag.org/docs/relay-proxy/getting_started |
| 23 | + // TODO create class to parse the configuration options see https://gofeatureflag.org/docs/relay-proxy/getting_started for available options |
| 24 | + // TODO how can I make this work on github? Can I start docker containers there? |
| 25 | + |
| 26 | + private static final DropwizardAppExtension<Config> APP = new DropwizardAppExtension<>( |
| 27 | + App.class, |
| 28 | + ResourceHelpers.resourceFilePath("go-feature-flag-provider-config.yml") |
| 29 | + ); |
| 30 | + |
| 31 | + @Test |
| 32 | + public void initializesHealthCheck() throws Exception { |
| 33 | + HealthCheck.Result healthcheckResult = APP.getEnvironment().healthChecks().runHealthCheck("openfeature-health-check"); |
| 34 | + assertTrue(healthcheckResult.isHealthy()); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void providesFeatureFlagsViaInMemoryProvider() throws Exception { |
| 39 | + // See flagd-test-flags.json for flag definitions used! |
| 40 | + Client client = OpenFeatureAPI.getInstance().getClient("go-feature-flag-client"); |
| 41 | + assertEquals("red", client.getStringValue("static-string-flag", "not-expected-value")); |
| 42 | + } |
| 43 | +} |
0 commit comments