-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
83 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,85 @@ | ||
package io.seqera.wavelit | ||
|
||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
import io.seqera.wave.api.ContainerConfig | ||
import io.seqera.wavelit.exception.IllegalCliArgumentException | ||
import picocli.CommandLine | ||
import spock.lang.Specification | ||
|
||
class AppTest extends Specification { | ||
|
||
@Subject | ||
App app = new App() | ||
def "test valid no entrypoint"() { | ||
given: | ||
def app = new App() | ||
String[] args = [] | ||
def cli = new CommandLine(app) | ||
|
||
when: | ||
cli.parseArgs(args) | ||
then: | ||
app.@entrypoint == null | ||
|
||
when: | ||
def config = app.prepareConfig() | ||
then: | ||
config == null | ||
} | ||
|
||
|
||
def "test valid entrypoint"() { | ||
given: | ||
def app = new App() | ||
String[] args = ["--config-entrypoint", "entryPoint"] | ||
def cli = new CommandLine(app) | ||
|
||
when: | ||
cli.parseArgs(args) | ||
then: | ||
app.@entrypoint == "entryPoint" | ||
|
||
when: | ||
def config = app.prepareConfig() | ||
then: | ||
config == new ContainerConfig(entrypoint: ['entryPoint']) | ||
} | ||
|
||
def "test invalid entrypoint"() { | ||
given: | ||
def app = new App() | ||
String[] args = ["--config-entrypoint"] | ||
|
||
when: | ||
new CommandLine(app).parseArgs(args) | ||
|
||
then: | ||
thrown(CommandLine.MissingParameterException) | ||
} | ||
|
||
def "test valid command"() { | ||
given: | ||
String[] args = ["--config-command", "command"] | ||
def app = new App() | ||
String[] args = ["--config-cmd", "/some/command"] | ||
|
||
when: | ||
new CommandLine(app).parseArgs(args) | ||
then: | ||
app.@command == "/some/command" | ||
|
||
when: | ||
def config = app.prepareConfig() | ||
then: | ||
app.command == "command" | ||
config == new ContainerConfig(cmd: ['/some/command']) | ||
} | ||
|
||
def "test invalid command"() { | ||
given: | ||
String[] args = ["--config-command"] | ||
def app = new App() | ||
String[] args = ["--config-cmd", ""] | ||
|
||
when: | ||
new CommandLine(app).parseArgs(args) | ||
|
||
app.prepareConfig() | ||
then: | ||
thrown(CommandLine.MissingParameterException) | ||
thrown(IllegalCliArgumentException) | ||
|
||
} | ||
} |