This repository has been archived by the owner on Sep 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d76ad4
commit 2d06944
Showing
15 changed files
with
296 additions
and
131 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
src/test/groovy/com/google/appengine/AppProjectTest.groovy
This file was deleted.
Oops, something went wrong.
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
110 changes: 110 additions & 0 deletions
110
src/test/groovy/com/google/gcloud/dsl/GCloudDslTest.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,110 @@ | ||
package com.google.gcloud.dsl | ||
|
||
import com.google.gradle.test.fixture.AppProjectBuilder | ||
import org.gradle.api.Project | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
|
||
import static org.junit.Assert.* | ||
|
||
/** | ||
* Test the parsing/execution of a build file with a gcloud configuration | ||
*/ | ||
class GCloudDslTest { | ||
|
||
static Project root | ||
static Project child1 | ||
static Project child2 | ||
|
||
@BeforeClass | ||
static void makeProject() { | ||
root = AppProjectBuilder.builder().withAppEngine().withGCloud().build() | ||
child1 = AppProjectBuilder.builder().withAppEngine().withParent(root).withName("child1").build() | ||
child2 = AppProjectBuilder.builder().withAppEngine().withParent(root).withName("child2").build() | ||
|
||
root.gcloud { | ||
configurations { | ||
allChildren { | ||
args project: "test-project" | ||
runArgs host: ":8889", "jvm-flag": ["-X1", "-X2"] | ||
deployArgs version: "tomato" | ||
modules ":child1", ":child2", ":child2" | ||
} | ||
onlyRoot { | ||
args project: "other-project" | ||
} | ||
indexes { | ||
args project: "other-other-project" | ||
descriptors "index.yaml", "index.yaml" | ||
} | ||
} | ||
} | ||
|
||
// make sure to evaluate the project, so we can see everything | ||
root.evaluate() | ||
} | ||
|
||
@Test | ||
void testTasks() { | ||
// why no assertEquals for ints? some autoboxing issue here | ||
assertEquals(3L, root.tasks.findAll { it.name.startsWith("gcloudAppDeploy") }.size()) | ||
|
||
assertNotNull(root.tasks.findByName("gcloudAppDeployAllChildren")) | ||
assertNotNull(root.tasks.findByName("gcloudAppDeployOnlyRoot")) | ||
assertNotNull(root.tasks.findByName("gcloudAppDeployIndexes")) | ||
|
||
assertTrue(root.tasks.findAll { it.name.startsWith("gcloudAppRun") }.size() == 2) | ||
assertNotNull(root.tasks.findByName("gcloudAppRunAllChildren")) | ||
assertNotNull(root.tasks.findByName("gcloudAppRunOnlyRoot")) | ||
|
||
assertTrue(root.tasks.findAll { it.name.startsWith("gcloudAppStop") }.size() == 2) | ||
assertNotNull(root.tasks.findByName("gcloudAppStopAllChildren")) | ||
assertNotNull(root.tasks.findByName("gcloudAppStopOnlyRoot")) | ||
} | ||
|
||
@Test | ||
void testExtension() { | ||
GCloudPluginExtension extension = root.extensions.gcloud | ||
|
||
assertEquals(3L, extension.configurations.size()) | ||
|
||
GCloudConfigurable allChildren = extension.configurations.findByName("allChildren") | ||
GCloudConfigurable onlyRoot = extension.configurations.findByName("onlyRoot") | ||
GCloudConfigurable indexes = extension.configurations.findByName("indexes") | ||
|
||
assertNotNull(allChildren) | ||
assertNotNull(onlyRoot) | ||
assertNotNull(indexes) | ||
|
||
assertEquals(1L, allChildren.args.size()) | ||
assertEquals(2L, allChildren.runArgs.size()) | ||
assertEquals(1L, allChildren.deployArgs.size()) | ||
assertEquals(1L, allChildren.descriptors.size()) | ||
assertEquals(2L, allChildren.modules.size()) | ||
assertEquals("test-project", allChildren.args.get("project")) | ||
assertEquals(":8889", allChildren.runArgs.get("host")) | ||
assertEquals("tomato", allChildren.deployArgs.get("version")) | ||
assertTrue(allChildren.descriptors.contains("app.yaml")) | ||
assertNotNull(allChildren.modules.find { Project p -> p.path.equals ":child1" }) | ||
assertNotNull(allChildren.modules.find { Project p -> p.path.equals ":child2" }) | ||
|
||
assertTrue(onlyRoot.args.size() == 1) | ||
assertTrue(onlyRoot.runArgs.size() == 0) | ||
assertTrue(onlyRoot.deployArgs.size() == 0) | ||
assertTrue(onlyRoot.descriptors.size() == 1) | ||
assertTrue(onlyRoot.modules.size() == 1) | ||
assertEquals("other-project", onlyRoot.args.get("project")) | ||
assertTrue(onlyRoot.descriptors.contains("app.yaml")) | ||
assertNotNull(onlyRoot.modules.find { Project p -> p.path.equals ":" }) | ||
|
||
assertTrue(indexes.args.size() == 1) | ||
assertTrue(indexes.runArgs.size() == 0) | ||
assertTrue(indexes.deployArgs.size() == 0) | ||
assertTrue(indexes.descriptors.size() == 1) | ||
assertTrue(indexes.modules.size() == 1) | ||
assertEquals("other-other-project", indexes.args.get("project")) | ||
assertTrue(indexes.descriptors.contains("index.yaml")) | ||
assertNotNull(indexes.modules.find { Project p -> p.path.equals ":" }) | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
src/test/groovy/com/google/gcloud/wrapper/CommandBuilderTest.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,75 @@ | ||
package com.google.gcloud.wrapper | ||
|
||
import aQute.libg.command.Command | ||
import com.beust.jcommander.internal.Lists | ||
import com.google.gcloud.exec.command.CommandBuilder | ||
import spock.lang.Ignore | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Command Builder test | ||
*/ | ||
class CommandBuilderTest extends Specification { | ||
def "Test command builder"() { | ||
given: "A builder" | ||
CommandBuilder builder = new CommandBuilder() | ||
|
||
when: "Create a command" | ||
builder.addCommand("gcloud", "test1", "test2") | ||
.addOption("bool1", true.toString()) | ||
.addOption("bool2", false.toString()) // false value | ||
.addArgument("path1") | ||
.addOption("opt1", "value") | ||
.addOption("--opt2", "value") | ||
.addOption("--multi", ["value1", "value2"]) | ||
.addArgument("path2"); | ||
String[] command = builder.buildCommand() | ||
|
||
then: "Check command and order" | ||
command.length == 10 | ||
command[0] == "gcloud" | ||
command[1] == "test1" | ||
command[2] == "test2" | ||
command[3] == "--bool1" | ||
command[4] == "--opt1=value" | ||
command[5] == "--opt2=value" | ||
command[6] == "--multi=value1" | ||
command[7] == "--multi=value2" | ||
command[8] == "path1" | ||
command[9] == "path2" | ||
} | ||
|
||
def "Illegal option test"() { | ||
given: "A builder" | ||
CommandBuilder builder = new CommandBuilder() | ||
|
||
when: "Illegal option added" | ||
builder.addOption(a, b) | ||
|
||
then: | ||
thrown(IllegalArgumentException) | ||
|
||
where: | ||
a | b | ||
null | "x" | ||
"" | "x" | ||
" "| "x" | ||
} | ||
|
||
def "Illegal argument test"() { | ||
given: "A builder" | ||
CommandBuilder builder = new CommandBuilder() | ||
|
||
when: "Illegal argument added" | ||
builder.addArgument(a) | ||
|
||
then: | ||
thrown(IllegalArgumentException) | ||
|
||
where: | ||
a | _ | ||
null | _ | ||
"" | _ | ||
" "| _ | ||
} | ||
} |
Oops, something went wrong.