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

v3.3.2 #66

Merged
merged 3 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions arkenv/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
base
kotlin("jvm") version "1.4.32"
id("org.jetbrains.dokka") version "1.4.32"
kotlin("jvm") version "1.5.10"
id("org.jetbrains.dokka") version "1.5.0"
id("java-test-fixtures")
signing
}
Expand All @@ -24,6 +24,7 @@ dependencies {
testFixturesApi("org.jmockit:jmockit:$jmockitVersion")
testFixturesApi("org.amshove.kluent:kluent:$kluentVersion")
testFixturesApi("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testFixturesApi("org.junit.jupiter:junit-jupiter-params:$junitVersion")
testFixturesApi("io.strikt:strikt-core:$striktVersion")

testImplementation(testFixtures(project(":arkenv")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal object ArkenvMapper {
Long::class -> toLongOrNull()
String::class -> this
Char::class -> firstOrNull()
Boolean::class -> toBoolean() || this == "1"
List::class, Collection::class -> split()
IntArray::class -> split().map(String::toInt).toIntArray()
ShortArray::class -> split().map(String::toShort).toShortArray()
Expand Down
30 changes: 30 additions & 0 deletions arkenv/src/test/kotlin/com/apurebase/arkenv/ParseClassTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import com.apurebase.arkenv.test.Expected
import com.apurebase.arkenv.util.argument
import com.apurebase.arkenv.util.parse
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import strikt.api.expectThat
import strikt.assertions.isEqualTo
import strikt.assertions.isFalse
import strikt.assertions.isNull
import strikt.assertions.isTrue

/**
* Tests for the [ArkenvParser.parseClass] functionality, parsing plain classes.
Expand Down Expand Up @@ -94,4 +98,30 @@ class ParseClassTests {
get { databasePort } isEqualTo Expected.databasePort
}
}

@ParameterizedTest
@ValueSource(strings = ["true", "1"])
fun `boolean true`(input: String) {
// Arrange
class Configuration(val headless: Boolean = false)

// Act
val config = Arkenv.parse<Configuration>(arrayOf("--headless", input))

// Assert
expectThat(config) { get { headless }.isTrue() }
}

@ParameterizedTest
@ValueSource(strings = ["false", "0", ""])
fun `boolean false`(input: String) {
// Arrange
class Configuration(val headless: Boolean = false)

// Act
val config = Arkenv.parse<Configuration>(arrayOf("--headless", input))

// Assert
expectThat(config) { get { headless }.isFalse() }
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.apurebase
version=3.3.1
version=3.3.2

# Versions
junitVersion=5.7.1
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists