Skip to content

Commit

Permalink
Merge pull request #66 from aPureBase/v3.3.2
Browse files Browse the repository at this point in the history
v3.3.2
  • Loading branch information
AndreasVolkmann authored Aug 19, 2021
2 parents 4a2630b + 586b0eb commit 2a9a86a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.3.2
* Fix boolean parsing in plain class (#65)

# 3.3.1
* Revert breaking change to argument name resolution.
The naming strategy can be changed in `configureArkenv`.
Expand Down
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

0 comments on commit 2a9a86a

Please sign in to comment.