Skip to content

Commit 6b7a8e9

Browse files
committed
Fix tests
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent 9d116ee commit 6b7a8e9

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

app/src/main/java/io/seqera/wave/cli/App.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ public class App implements Runnable {
186186
@Option(names = {"--name-strategy"}, paramLabel = "false", description = "Specify the name strategy for the container name, it can be 'none' or 'tagPrefix' or 'imageSuffix'", hidden = true)
187187
private ImageNameStrategy nameStrategy;
188188

189-
@Option(names = {"--mirror-to"}, paramLabel = "false", description = "Specify registry where the container should be mirrored e.g. 'docker.io'")
190-
private String mirrorToRegistry;
189+
@Option(names = {"-m","--mirror-registry"}, paramLabel = "false", description = "Specify registry where the container should be mirrored e.g. 'docker.io'")
190+
private String mirrorRegistry;
191191

192-
@Option(names = {"--scan-mode"}, paramLabel = "false", description = "Specify container security scan mode, it can be 'none', 'lazy' 'async' or 'sync'")
192+
@Option(names = {"--scan-mode"}, paramLabel = "false", description = "Specify container security scan mode, it can be 'none', 'async' or 'required'")
193193
private ScanMode scanMode;
194194

195195
@Option(names = {"--scan-level"}, paramLabel = "false", description = "Specify one or more security scan vulnerabilities level allowed in the container e.g. low,medium,high,critical")
@@ -354,26 +354,26 @@ protected void validateArgs() {
354354
throw new IllegalCliArgumentException("Context path is not a directory - offending value: " + contextDir);
355355
}
356356

357-
if( !isEmpty(mirrorToRegistry) && !isEmpty(containerFile) )
358-
throw new IllegalCliArgumentException("Argument --mirror-to and --containerfile conflict each other");
357+
if( !isEmpty(mirrorRegistry) && !isEmpty(containerFile) )
358+
throw new IllegalCliArgumentException("Argument --mirror-registry and --containerfile conflict each other");
359359

360-
if( !isEmpty(mirrorToRegistry) && !isEmpty(condaFile) )
361-
throw new IllegalCliArgumentException("Argument --mirror-to and --conda-file conflict each other");
360+
if( !isEmpty(mirrorRegistry) && !isEmpty(condaFile) )
361+
throw new IllegalCliArgumentException("Argument --mirror-registry and --conda-file conflict each other");
362362

363-
if( !isEmpty(mirrorToRegistry) && !isEmpty(condaPackages) )
364-
throw new IllegalCliArgumentException("Argument --mirror-to and --conda-package conflict each other");
363+
if( !isEmpty(mirrorRegistry) && !isEmpty(condaPackages) )
364+
throw new IllegalCliArgumentException("Argument --mirror-registry and --conda-package conflict each other");
365365

366-
if( !isEmpty(mirrorToRegistry) && !isEmpty(contextDir) )
367-
throw new IllegalCliArgumentException("Argument --mirror-to and --context conflict each other");
366+
if( !isEmpty(mirrorRegistry) && !isEmpty(contextDir) )
367+
throw new IllegalCliArgumentException("Argument --mirror-registry and --context conflict each other");
368368

369-
if( !isEmpty(mirrorToRegistry) && freeze )
370-
throw new IllegalCliArgumentException("Argument --mirror-to and --freeze conflict each other");
369+
if( !isEmpty(mirrorRegistry) && freeze )
370+
throw new IllegalCliArgumentException("Argument --mirror-registry and --freeze conflict each other");
371371

372-
if( !isEmpty(mirrorToRegistry) && !isEmpty(buildRepository) )
373-
throw new IllegalCliArgumentException("Argument --mirror-to and --build-repository conflict each other");
372+
if( !isEmpty(mirrorRegistry) && !isEmpty(buildRepository) )
373+
throw new IllegalCliArgumentException("Argument --mirror-registry and --build-repository conflict each other");
374374

375-
if( !isEmpty(mirrorToRegistry) && !isEmpty(cacheRepository) )
376-
throw new IllegalCliArgumentException("Argument --mirror-to and --cache-repository conflict each other");
375+
if( !isEmpty(mirrorRegistry) && !isEmpty(cacheRepository) )
376+
throw new IllegalCliArgumentException("Argument --mirror-registry and --cache-repository conflict each other");
377377

378378
if( dryRun && await != null )
379379
throw new IllegalCliArgumentException("Options --dry-run and --await conflicts each other");
@@ -406,7 +406,7 @@ protected SubmitContainerTokenRequest createRequest() {
406406
.withDryRun(dryRun)
407407
.withContainerIncludes(includes)
408408
.withNameStrategy(nameStrategy)
409-
.withMirrorRegistry(mirrorToRegistry)
409+
.withMirrorRegistry(mirrorRegistry)
410410
.withScanMode(scanMode)
411411
.withScanLevels(scanLevels)
412412
;

app/src/test/groovy/io/seqera/wave/cli/AppTest.groovy

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class AppTest extends Specification {
100100
)
101101
def status = new ContainerStatusResponse(
102102
"12345",
103-
ContainerStatus.READY,
103+
ContainerStatus.DONE,
104104
"98765",
105105
null,
106106
"scan-1234",
107-
[medium:1, high:2],
107+
[MEDIUM:1, HIGH:2],
108108
true,
109109
"All ok",
110110
"http://foo.com",
@@ -125,12 +125,12 @@ class AppTest extends Specification {
125125
duration: PT1M
126126
expiration: '1970-01-20T13:57:19.913Z'
127127
reason: All ok
128-
status: READY
128+
status: DONE
129129
succeeded: true
130130
targetImage: docker.io/some/repo
131131
vulnerabilities:
132-
medium: 1
133-
high: 2
132+
MEDIUM: 1
133+
HIGH: 2
134134
'''.stripIndent(true)
135135
}
136136

@@ -257,15 +257,15 @@ class AppTest extends Specification {
257257
def 'should set scan levels' () {
258258
given:
259259
def app = new App()
260-
String[] args = ["--scan-level", 'low', "--scan-level", 'medium']
260+
String[] args = ["--scan-level", 'LOW', "--scan-level", 'MEDIUM']
261261

262262
when:
263263
new CommandLine(app).parseArgs(args)
264264
and:
265265
def req = app.createRequest()
266266
then:
267267
req.scanMode == null
268-
req.scanLevels == List.of(ScanLevel.low, ScanLevel.medium)
268+
req.scanLevels == List.of(ScanLevel.LOW, ScanLevel.MEDIUM)
269269
}
270270

271271
def 'should not allow dry-run and await' () {
@@ -470,7 +470,7 @@ class AppTest extends Specification {
470470
def 'should fail when specifying mirror registry and container file' () {
471471
given:
472472
def app = new App()
473-
String[] args = ["--mirror-to", "docker.io", "-f", "foo"]
473+
String[] args = ["--mirror-registry", "docker.io", "-f", "foo"]
474474

475475
when:
476476
def cli = new CommandLine(app)
@@ -480,13 +480,13 @@ class AppTest extends Specification {
480480
then:
481481
def e = thrown(IllegalCliArgumentException)
482482
and:
483-
e.getMessage() == "Argument --mirror-to and --containerfile conflict each other"
483+
e.getMessage() == "Argument --mirror-registry and --containerfile conflict each other"
484484
}
485485

486486
def 'should fail when specifying mirror registry and conda package' () {
487487
given:
488488
def app = new App()
489-
String[] args = ["--mirror-to", "docker.io", "--conda-package", "foo"]
489+
String[] args = ["--mirror-registry", "docker.io", "--conda-package", "foo"]
490490

491491
when:
492492
def cli = new CommandLine(app)
@@ -496,13 +496,13 @@ class AppTest extends Specification {
496496
then:
497497
def e = thrown(IllegalCliArgumentException)
498498
and:
499-
e.getMessage() == "Argument --mirror-to and --conda-package conflict each other"
499+
e.getMessage() == "Argument --mirror-registry and --conda-package conflict each other"
500500
}
501501

502502
def 'should fail when specifying mirror registry and freeze' () {
503503
given:
504504
def app = new App()
505-
String[] args = ["--mirror-to", "docker.io", "--image", "foo", "--freeze"]
505+
String[] args = ["--mirror-registry", "docker.io", "--image", "foo", "--freeze"]
506506

507507
when:
508508
def cli = new CommandLine(app)
@@ -512,7 +512,7 @@ class AppTest extends Specification {
512512
then:
513513
def e = thrown(IllegalCliArgumentException)
514514
and:
515-
e.getMessage() == "Argument --mirror-to and --freeze conflict each other"
515+
e.getMessage() == "Argument --mirror-registry and --freeze conflict each other"
516516
}
517517

518518
}

0 commit comments

Comments
 (0)