-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a flag to allow minor updates (#708)
- Loading branch information
Showing
3 changed files
with
132 additions
and
11 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
70 changes: 70 additions & 0 deletions
70
src/test/groovy/io/micronaut/build/catalogs/tasks/VersionCatalogUpdateTest.groovy
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,70 @@ | ||
package io.micronaut.build.catalogs.tasks | ||
|
||
import org.gradle.api.artifacts.ComponentSelection | ||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier | ||
import spock.lang.Specification | ||
|
||
import static io.micronaut.build.catalogs.tasks.VersionCatalogUpdate.maybeRejectVersionByMinorMajor | ||
|
||
class VersionCatalogUpdateTest extends Specification { | ||
def "test major and minor version extraction"() { | ||
expect: | ||
VersionCatalogUpdate.majorVersionOf(version) == expectedMajor | ||
VersionCatalogUpdate.minorVersionOf(version) == expectedMinor | ||
|
||
where: | ||
version | expectedMajor | expectedMinor | ||
"1.2.3" | 1 | 2 | ||
"1.2" | 1 | 2 | ||
"1" | 1 | 0 | ||
"1.2.3.4" | 1 | 2 | ||
"3.5-beta" | 3 | 5 | ||
"3.5-beta1" | 3 | 5 | ||
"2.1.0-rc1" | 2 | 1 | ||
"128.256.12" | 128 | 256 | ||
// not semantic versioning, edge cases to make sure | ||
// the implementation is robust enough | ||
"abc.def" | 0 | 0 | ||
"oh.123noes" | 0 | 123 | ||
"" | 0 | 0 | ||
"wut" | 0 | 0 | ||
} | ||
|
||
def "tests rejection rules"() { | ||
def componentSelection = Mock(ComponentSelection) | ||
def log = Stub(PrintWriter) | ||
def id = Stub(ModuleComponentIdentifier) { | ||
getGroup() >> "io.micronaut" | ||
getModule() >> "micronaut-core" | ||
getVersion() >> candidateVersion | ||
} | ||
|
||
when: | ||
maybeRejectVersionByMinorMajor( | ||
componentSelection, | ||
allowMajorUpdate, | ||
allowMinorUpdate, | ||
currentVersion, | ||
candidateVersion, | ||
log, | ||
id | ||
) | ||
|
||
then: | ||
reject * componentSelection.reject(_) | ||
|
||
where: | ||
allowMajorUpdate | allowMinorUpdate | currentVersion | candidateVersion | reject | ||
false | false | '1.0.0' | '2.0.0' | 1 | ||
false | false | '1.0.0' | '1.1.0' | 1 | ||
false | false | '1.0.0' | '1.0.1' | 0 | ||
false | true | '1.0.0' | '1.1.0' | 0 | ||
false | true | '1.0.0' | '2.0.0' | 1 | ||
true | false | '1.0.0' | '2.0.0' | 0 | ||
true | false | '1.0.0' | '1.1.0' | 1 | ||
true | false | '1.0.0' | '1.0.1' | 0 | ||
true | true | '1.0.0' | '2.0.0' | 0 | ||
true | true | '1.0.0' | '1.1.0' | 0 | ||
true | true | '1.0.0' | '1.0.1' | 0 | ||
} | ||
} |