-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve version regex and add tests (#616)
Co-authored-by: Joaquim Stähli <[email protected]>
- Loading branch information
Showing
8 changed files
with
95 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
build-logic/plugins/src/test/java/ch/srgssr/pillarbox/gradle/internal/VersionConfigTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle.internal | ||
|
||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
import org.junit.runners.Parameterized.Parameters | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
@RunWith(Parameterized::class) | ||
class VersionConfigTest( | ||
private val envVersionName: String?, | ||
private val versionName: String, | ||
private val versionCode: Int, | ||
) { | ||
private lateinit var versionConfig: VersionConfig | ||
|
||
@BeforeTest | ||
fun setUp() { | ||
versionConfig = VersionConfig(envVersionName) | ||
} | ||
|
||
@Test | ||
fun `version name`() { | ||
assertEquals(versionName, versionConfig.versionName()) | ||
} | ||
|
||
@Test | ||
fun `version code`() { | ||
assertEquals(versionCode, versionConfig.versionCode()) | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@Parameters(name = "{index}: envVersionName={0}, versionName={1}, versionCode={2}") | ||
fun parameters(): Iterable<Any> { | ||
return listOf( | ||
// Invalid envVersionName | ||
arrayOf(null, "Local", 9999), | ||
arrayOf("", "", 9999), | ||
arrayOf("Foo", "Foo", 9999), | ||
|
||
// Invalid version format | ||
arrayOf("1.2", "1.2", 9999), | ||
arrayOf("1a2b3", "1a2b3", 9999), | ||
arrayOf("1.2.3.4", "1.2.3.4", 9999), | ||
arrayOf("111.2.3", "111.2.3", 9999), | ||
arrayOf("1.222.3", "1.222.3", 9999), | ||
arrayOf("1.2.333", "1.2.333", 9999), | ||
|
||
// Valid version format | ||
arrayOf("0.0.0", "0.0.0", 0), | ||
arrayOf("1.2.3", "1.2.3", 10203), | ||
arrayOf("12.34.56", "12.34.56", 123456), | ||
arrayOf("01.02.03", "01.02.03", 10203), | ||
arrayOf("99.99.99", "99.99.99", 999999), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters