-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new test using GradleRunner that actually tests toGDrive copy
- Loading branch information
1 parent
2e9121d
commit efc23e0
Showing
1 changed file
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package oger.util.java | ||
|
||
|
||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import spock.lang.Specification | ||
import spock.lang.TempDir | ||
|
||
class ToGDriveSpec extends Specification { | ||
|
||
@TempDir | ||
File testProjectDir | ||
File settingsFile | ||
File buildFile | ||
File outJar | ||
|
||
def setup() { | ||
settingsFile = new File(testProjectDir, 'settings.gradle') | ||
buildFile = new File(testProjectDir, 'build.gradle') | ||
|
||
// use this to test real path and remove environment below: def basePath = [email protected]() | ||
def basePath = testProjectDir.toPath() | ||
outJar = basePath.resolve("syncme/gradle_jars/oger.test.jar").toFile() | ||
outJar.delete() | ||
} | ||
|
||
def cleanup() { | ||
outJar.delete() | ||
} | ||
|
||
def "actually copies files with toGDrive"() { | ||
given: | ||
settingsFile << "rootProject.name = 'oger.test'" | ||
buildFile << """ | ||
plugins { | ||
id 'com.github.itsnotoger.gradle-plugin' | ||
} | ||
gdrive { | ||
debug = true | ||
type = oger.util.java.Type.JARLIBRARY | ||
GDriveJars = "/syncme/gradle_jars" | ||
GDriveApps = "/gradle_apps" | ||
mainClass = "oger.util.java.OgerPluginSpec" | ||
} | ||
""" | ||
|
||
when: | ||
def result = GradleRunner.create() | ||
.withProjectDir(testProjectDir) | ||
.withArguments('toGDrive') | ||
.withPluginClasspath() | ||
.withEnvironment(Map.of("GDRIVE", testProjectDir.toString())) | ||
.build() | ||
|
||
println getClass().getSimpleName() + " test build output { \n\t" + result.output.split("\n").join("\n\t") + "}" | ||
|
||
then: | ||
result.output.contains('toGDrive') | ||
result.task(":toGDrive").outcome == TaskOutcome.SUCCESS | ||
outJar.exists() | ||
} | ||
} |