Skip to content

Commit

Permalink
checking the env variables
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Dmytrenko <[email protected]>
  • Loading branch information
erka committed Jan 8, 2025
1 parent bc2b4f6 commit e072cf5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
13 changes: 6 additions & 7 deletions flipt-client-kotlin-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ android {
ndk {
abiFilters "x86_64", "arm64-v8a"
}
def fliptUrl = System.getenv("FLIPT_URL") ?: ""
def fliptAuthToken = System.getenv("FLIPT_AUTH_TOKEN") ?: ""
buildConfigField("String", "FLIPT_URL", "\"$fliptUrl\"")
buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"$fliptAuthToken\"")
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField("String", "FLIPT_URL", "\"${System.getenv("FLIPT_URL") ?: ""}\"")
buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"${System.getenv("FLIPT_AUTH_TOKEN") ?: ""}\"")
}
debug {
buildConfigField("String", "FLIPT_URL", "\"${System.getenv("FLIPT_URL") ?: ""}\"")
buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"${System.getenv("FLIPT_AUTH_TOKEN") ?: ""}\"")
}
}
compileOptions {
Expand All @@ -38,6 +36,7 @@ android {

kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
}

externalNativeBuild {
Expand All @@ -53,4 +52,4 @@ dependencies {
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.espresso.core
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.junit.After
import org.junit.Before
import org.junit.Test


class TestFliptEvaluationClient {
private var fliptClient: FliptEvaluationClient? = null

Expand All @@ -15,14 +14,16 @@ class TestFliptEvaluationClient {
fun initAll() {
val fliptURL = BuildConfig.FLIPT_URL
val clientToken = BuildConfig.FLIPT_AUTH_TOKEN

assert("http://10.0.2.2:8080" == fliptURL)
assert(!fliptURL.isEmpty())
assert(!clientToken.isEmpty())
fliptClient = FliptEvaluationClient.builder()
.url(url = fliptURL)
.namespace("default")
.authentication(ClientTokenAuthentication(clientToken))
.build()
fliptClient =
FliptEvaluationClient
.builder()
.url(url = fliptURL)
.namespace("default")
.authentication(ClientTokenAuthentication(clientToken))
.build()
}

@Test
Expand All @@ -31,7 +32,7 @@ class TestFliptEvaluationClient {
val context: MutableMap<String, String> = HashMap()
context["fizz"] = "buzz"

val response = fliptClient?.evaluateVariant("flag1", "entity", context)
val response = fliptClient?.evaluateVariant("flag1", "entity", context)

assert("flag1" == response?.flagKey)
assert(response?.match ?: false)
Expand Down Expand Up @@ -59,19 +60,20 @@ class TestFliptEvaluationClient {
val context: MutableMap<String, String> = HashMap()
context["fizz"] = "buzz"

val evalRequests: Array<EvaluationRequest> = arrayOf(
EvaluationRequest("flag1", "entity", context),
EvaluationRequest("flag_boolean", "entity", context),
EvaluationRequest("notfound", "entity", context)
)
val evalRequests: Array<EvaluationRequest> =
arrayOf(
EvaluationRequest("flag1", "entity", context),
EvaluationRequest("flag_boolean", "entity", context),
EvaluationRequest("notfound", "entity", context),
)

val response = fliptClient?.evaluateBatch(evalRequests)

assert(3 == response?.responses?.size)
val responses = response?.responses

assert(responses?.get(0)?.variantEvaluationResponse != null)
val variantResponse = responses?.get(0)?.variantEvaluationResponse
val variantResponse = responses?.get(0)?.variantEvaluationResponse
assert("flag1" == variantResponse?.flagKey)
assert(variantResponse?.match ?: false)
assert("MATCH_EVALUATION_REASON" == variantResponse?.reason)
Expand Down Expand Up @@ -103,5 +105,4 @@ class TestFliptEvaluationClient {
fun tearDownAll() {
fliptClient?.close()
}

}

0 comments on commit e072cf5

Please sign in to comment.