Skip to content

Commit

Permalink
fix: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Nov 22, 2017
1 parent e7426f0 commit d03d775
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'groovy'
id 'java-gradle-plugin'
id 'maven-publish'
id 'com.widen.versioning' version '0.1.0'
Expand Down Expand Up @@ -34,13 +35,16 @@ publishing {

dependencies {
compile 'commons-io:commons-io:2.6'

testCompile 'org.codehaus.groovy:groovy-all:2.4.12'
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
}

gradlePlugin {
plugins {
versioning {
id = "com.widen.versioning"
implementationClass = "com.widen.versioning.VersioningPlugin"
id = 'com.widen.versioning'
implementationClass = 'com.widen.versioning.VersioningPlugin'
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/widen/versioning/VersionGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public static String generateFromGit() {
}

public static String generateFromString(String describe) {
if (describe == null) {
return "";
}
return describe.replaceFirst("-", "+");
}
}
18 changes: 18 additions & 0 deletions src/test/groovy/com/widen/versioning/VersionGeneratorTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.widen.versioning

import spock.lang.Specification
import spock.lang.Unroll

class VersionGeneratorTest extends Specification {
@Unroll("git describe '#describe' should become '#version'")
def "parse git describe to version"() {
expect:
VersionGenerator.generateFromString(describe) == version

where:
describe | version
null | ""
"" | ""
"0.1.0-4-ge7426f0" | "0.1.0+4-ge7426f0"
}
}

0 comments on commit d03d775

Please sign in to comment.