File tree 1 file changed +2
-0
lines changed
test/com/cloudogu/ces/cesbuildlib
1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -46,13 +46,15 @@ class TrivyTest extends GroovyTestCase {
46
46
when(imageMock. inside(matches(" -v /test/.trivy/.cache:/root/.cache/" ), any())). thenAnswer(new Answer<Integer > () {
47
47
@Override
48
48
Integer answer (InvocationOnMock invocation ) throws Throwable {
49
+ // mock "sh trivy" so that it returns the expected status code and check trivy arguments
49
50
Integer expectedStatusCode = 0
50
51
Closure closure = invocation. getArgument(1 )
51
52
scriptMock. expectedShRetValueForScript. put(expectedTrivyCommand, expectedStatusCode)
52
53
Integer statusCode = closure. call() as Integer
53
54
assertEquals (expectedStatusCode, statusCode)
54
55
assertEquals (expectedTrivyCommand, scriptMock. getActualShMapArgs(). getLast())
55
56
57
+ // emulate trivy call with local trivy installation and check that it has the same behavior
56
58
Files . createDirectories(trivyDir)
57
59
Process process = trivyExec. exec(Trivy . DEFAULT_TRIVY_VERSION , trivyArguments, workDir)
58
60
if (process. waitFor(2 , TimeUnit . MINUTES )) {
You can’t perform that action at this time.
0 commit comments