Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
munishchouhan committed May 21, 2024
1 parent 189ee7d commit 50759c6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package io.seqera.wave.cli

import io.seqera.wave.api.ImageNameStrategy
import io.seqera.wave.cli.util.DurationConverter

import java.nio.file.Files
Expand Down Expand Up @@ -340,4 +341,36 @@ class AppTest extends Specification {
app.prompt == ['Get a docker container']
}

def 'should get the correct name strategy'(){
given:
def app = new App()
String[] args = ["-i", "ubuntu:latest", "--name-strategy", "tagPrefix"]

when:
def cli = new CommandLine(app)
cli.parseArgs(args)
and:
app.validateArgs()
then:
noExceptionThrown()
and:
app.@nameStrategy == ImageNameStrategy.tagPrefix
}

def 'should fail when passing incorrect name strategy'(){
given:
def app = new App()
String[] args = ["-i", "ubuntu:latest", "--name-strategy", "wrong"]

when:
def cli = new CommandLine(app)
cli.parseArgs(args)
and:
app.validateArgs()
then:
def e = thrown(CommandLine.ParameterException)
and:
e.getMessage() == "Invalid value for option '--name-strategy': expected one of [none, tagPrefix, imageSuffix] (case-sensitive) but was 'wrong'"
}

}

0 comments on commit 50759c6

Please sign in to comment.