-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #622 fix: evaluate also instance VersionVersionProperties.Incrementer to run in right condition if dsl is kotlin Test & Documentation * #622 fix: evaluate also instance VersionVersionProperties.Creator to run in right condition if dsl is kotlin Test & Documentation
- Loading branch information
Showing
4 changed files
with
112 additions
and
3 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
96 changes: 96 additions & 0 deletions
96
...ation/groovy/pl/allegro/tech/build/axion/release/BranchVersionCreatorKotlinDslTest.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,96 @@ | ||
package pl.allegro.tech.build.axion.release | ||
|
||
import org.ajoberstar.grgit.Grgit | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import pl.allegro.tech.build.axion.release.domain.LocalOnlyResolver | ||
import pl.allegro.tech.build.axion.release.domain.properties.PropertiesBuilder | ||
import pl.allegro.tech.build.axion.release.domain.scm.ScmProperties | ||
import pl.allegro.tech.build.axion.release.domain.scm.ScmRepository | ||
import pl.allegro.tech.build.axion.release.infrastructure.di.ScmRepositoryFactory | ||
import pl.allegro.tech.build.axion.release.infrastructure.di.VersionResolutionContext | ||
import spock.lang.Specification | ||
import spock.lang.TempDir | ||
|
||
import static pl.allegro.tech.build.axion.release.domain.scm.ScmPropertiesBuilder.scmProperties | ||
|
||
class BranchVersionCreatorKotlinDslTest extends Specification { | ||
|
||
@TempDir | ||
File temporaryFolder | ||
|
||
ScmRepository repository | ||
|
||
VersionResolutionContext context | ||
|
||
void setup() { | ||
def rawRepository = Grgit.init(dir: temporaryFolder) | ||
|
||
// let's make sure, not to use system wide user settings in tests | ||
rawRepository.repository.jgit.repository.config.baseConfig.clear() | ||
|
||
ScmProperties scmProperties = scmProperties(temporaryFolder).build() | ||
ScmRepository scmRepository = ScmRepositoryFactory.create(scmProperties) | ||
|
||
context = new VersionResolutionContext( | ||
PropertiesBuilder.properties().build(), | ||
scmRepository, | ||
scmProperties, | ||
temporaryFolder, | ||
new LocalOnlyResolver(true) | ||
) | ||
|
||
repository = context.repository() | ||
repository.commit(['*'], 'initial commit') | ||
repository.tag("V1.0.0") | ||
|
||
} | ||
|
||
|
||
def "should not fail using closure as argument for branchVersionIncrementer"() { | ||
given: | ||
|
||
new FileTreeBuilder(temporaryFolder).file("build.gradle.kts", | ||
""" | ||
import com.github.zafarkhaja.semver.Version | ||
import pl.allegro.tech.build.axion.release.domain.VersionIncrementerContext | ||
import pl.allegro.tech.build.axion.release.domain.properties.VersionProperties | ||
import pl.allegro.tech.build.axion.release.domain.scm.ScmPosition | ||
plugins { | ||
id ("pl.allegro.tech.build.axion-release") | ||
} | ||
scmVersion { | ||
tag { | ||
prefix.set("V") | ||
} | ||
ignoreUncommittedChanges.set(false) | ||
branchVersionCreator.putAll( | ||
mapOf( | ||
"master" to VersionProperties.Creator { s: String, scmPosition: ScmPosition -> "\${s}-\${scmPosition.branch}"} | ||
) | ||
) | ||
} | ||
project.version = scmVersion.version | ||
""") | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(temporaryFolder) | ||
.withPluginClasspath() | ||
.withArguments('currentVersion', '-s') | ||
.build() | ||
|
||
then: | ||
result.output.contains(" 1.0.1-master-SNAPSHOT") | ||
result.task(":currentVersion").outcome == TaskOutcome.SUCCESS | ||
|
||
|
||
} | ||
} |
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