Skip to content

Commit

Permalink
Merge pull request #14 from noumenalio/develop
Browse files Browse the repository at this point in the history
Full FunctionalTest
  • Loading branch information
stewartbryson authored Aug 18, 2022
2 parents a45e304 + de4ca0f commit cc7949c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
35 changes: 33 additions & 2 deletions plugin/src/functionalTest/groovy/io/noumenal/FunctionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FunctionalTest extends Specification {
private File projectDir

@Shared
File buildFile, settingsFile
File buildFile, settingsFile, javaFile

@Shared
String account = System.getProperty("account"),
Expand All @@ -41,15 +41,46 @@ class FunctionalTest extends Specification {
|plugins {
| id('io.noumenal.gradle.snowflake')
|}
|java {
| toolchain {
| languageVersion = JavaLanguageVersion.of(11)
| }
|}
|snowflake {
| groupId = 'io.noumenal'
| artifactId = 'test-gradle-snowflake'
| role = 'devops'
| database = 'devops'
| schema = 'gradle'
| applications {
| add_numbers {
| inputs = ["a integer", "b integer"]
| returns = "string"
| handler = "AddNumbers.addNum"
| }
| }
|}
|version='0.1.0'
|""".stripMargin())
javaFile = new File("${projectDir}/src/main/java", 'AddNumbers.java')
javaFile.parentFile.mkdirs()
javaFile.write("""
|public class AddNumbers
|{
| public String addNum(int num1, int num2) {
| try {
| int sum = num1 + num2;
| return ("Sum is: " + sum);
| } catch (Exception e) {
| return e.toString();
| }
| }
|
| public static void main(String[] args){
| System.out.println("Hello World");
| }
|}
|""".stripMargin())
}

// helper method
Expand Down Expand Up @@ -105,7 +136,7 @@ class FunctionalTest extends Specification {
taskName = 'snowflakePublish'

when:
result = executeSingleTask(taskName, ['--jar', 'build/libs/unit-test-0.1.0-all.jar','-Psnowflake.stage=upload', '-Si'])
result = executeSingleTask(taskName, ['--jar', 'build/libs/unit-test-0.1.0-all.jar', '-Psnowflake.stage=upload', '-Si'])

then:
!result.tasks.collect { it.outcome }.contains('FAILURE')
Expand Down
8 changes: 6 additions & 2 deletions plugin/src/main/groovy/io/noumenal/SnowflakePublish.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ class SnowflakePublish extends DefaultTask {
AUTO_COMPRESS: 'false',
PARALLEL : '4'
]
PutResult[] putResults = session.file().put(jar, "$stage/libs", options)
PutResult[] pr = session.file().put(jar, "$stage/libs", options)
pr.each {
log.warn "File ${it.sourceFileName}: ${it.status}"
}
} else {
// ensure that the stage and the publishUrl are aligned
Statement statement = session.jdbcConnection().createStatement()
Expand All @@ -227,7 +230,8 @@ class SnowflakePublish extends DefaultTask {
// automatically create application spec objects
output.write("Snowflake Application:\n\n")
project."$PLUGIN".applications.each { ApplicationContainer app ->
String createText = app.getCreate(extension.publishUrl ? getImports(session) : "@$stage/libs/$jar")
File jarFile = project.file(jar)
String createText = app.getCreate(extension.publishUrl ? getImports(session) : "'@$stage/libs/${jarFile.name}'")
String message = "Deploying ==> \n$createText"
log.warn message
output.append("$message\n")
Expand Down

0 comments on commit cc7949c

Please sign in to comment.