-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from caelwinner/validation-task
#273: Adding deployment validation task
- Loading branch information
Showing
6 changed files
with
109 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
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
25 changes: 25 additions & 0 deletions
25
...oovy/org/fundacionjala/gradle/plugins/enforce/tasks/salesforce/deployment/Validate.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,25 @@ | ||
package org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment | ||
|
||
import org.fundacionjala.gradle.plugins.enforce.utils.Constants | ||
|
||
/** | ||
* Deploy performing validation in all project source | ||
*/ | ||
class Validate extends Deploy { | ||
private static final String VALIDATING_CODE = 'Starting validation' | ||
|
||
/** | ||
* Sets description task and its group | ||
*/ | ||
Validate() { | ||
super() | ||
this.description = VALIDATING_CODE | ||
this.group = Constants.DEPLOYMENT | ||
} | ||
|
||
@Override | ||
void runTask() { | ||
checkOnly = true | ||
super.runTask() | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
.../org/fundacionjala/gradle/plugins/enforce/tasks/salesforce/deployment/ValidateTest.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,59 @@ | ||
package org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment | ||
|
||
import org.fundacionjala.gradle.plugins.enforce.EnforcePlugin | ||
import org.fundacionjala.gradle.plugins.enforce.metadata.DeployMetadata | ||
import org.fundacionjala.gradle.plugins.enforce.utils.ManagementFile | ||
import org.gradle.api.Project | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
import java.nio.file.Paths | ||
|
||
class ValidateTest extends Specification { | ||
@Shared | ||
Project project | ||
|
||
@Shared | ||
def instanceDeploy | ||
|
||
def deployMetadata = Mock(DeployMetadata) | ||
|
||
@Shared | ||
def SRC_PATH = Paths.get(System.getProperty("user.dir"), "src", "test", "groovy", "org", | ||
"fundacionjala", "gradle", "plugins","enforce","tasks", "salesforce", "resources").toString() | ||
|
||
def setup() { | ||
project = ProjectBuilder.builder().build() | ||
project.apply(plugin: EnforcePlugin) | ||
project.enforce.srcPath = SRC_PATH | ||
instanceDeploy = project.tasks.validate | ||
instanceDeploy.fileManager = new ManagementFile(SRC_PATH) | ||
instanceDeploy.project.enforce.deleteTemporaryFiles = false | ||
instanceDeploy.createDeploymentDirectory(Paths.get(SRC_PATH, 'build').toString()) | ||
instanceDeploy.createDeploymentDirectory(Paths.get(SRC_PATH, 'build', 'deploy').toString()) | ||
instanceDeploy.createDeploymentDirectory(Paths.get(SRC_PATH, 'build', 'deploy', 'folderOne').toString()) | ||
instanceDeploy.componentDeploy = deployMetadata | ||
} | ||
|
||
def "should perform validation"() { | ||
given: | ||
instanceDeploy.buildFolderPath = Paths.get(SRC_PATH, 'build').toString() | ||
instanceDeploy.projectPath = Paths.get(SRC_PATH, 'src').toString() | ||
instanceDeploy.project.enforce.deleteTemporaryFiles = true | ||
instanceDeploy.projectPackagePath = Paths.get(SRC_PATH, 'src', 'package.xml').toString() | ||
String folderDeploy = Paths.get(SRC_PATH, 'build', 'deploy').toString() | ||
|
||
and: | ||
instanceDeploy.setup() | ||
instanceDeploy.createDeploymentDirectory(folderDeploy) | ||
instanceDeploy.displayFolderNoDeploy() | ||
instanceDeploy.deployAllComponents() | ||
instanceDeploy.deleteTemporaryFiles() | ||
|
||
when: | ||
instanceDeploy.runTask() | ||
then: | ||
2 * deployMetadata.deploy(_, _, _, _, true) | ||
} | ||
} |