-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
LambdaDevServicesContinuousTestingTestCase.java
52 lines (46 loc) · 2.36 KB
/
LambdaDevServicesContinuousTestingTestCase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.quarkus.amazon.lambda.deployment.testing;
import java.util.function.Supplier;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.quarkus.test.ContinuousTestingTestUtils;
import io.quarkus.test.QuarkusDevModeTest;
public class LambdaDevServicesContinuousTestingTestCase {
@RegisterExtension
public static QuarkusDevModeTest test = new QuarkusDevModeTest()
.setArchiveProducer(new Supplier<>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(GreetingLambda.class, Person.class)
.addAsResource(
new StringAsset(ContinuousTestingTestUtils.appProperties(
"quarkus.log.category.\"io.quarkus.amazon.lambda.runtime\".level=DEBUG")),
"application.properties");
}
}).setTestArchiveProducer(new Supplier<>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class).addClass(LambdaHandlerET.class);
}
});
//run this twice, to make sure everything is cleaned up properly
@RepeatedTest(2)
public void testLambda() throws Exception {
ContinuousTestingTestUtils utils = new ContinuousTestingTestUtils();
var result = utils.waitForNextCompletion();
Assertions.assertEquals(1, result.getTotalTestsPassed());
Assertions.assertEquals(0, result.getTotalTestsFailed());
test.modifySourceFile(GreetingLambda.class, s -> s.replace("Hey", "Yo"));
result = utils.waitForNextCompletion();
Assertions.assertEquals(0, result.getTotalTestsPassed());
Assertions.assertEquals(1, result.getTotalTestsFailed());
test.modifyTestSourceFile(LambdaHandlerET.class, s -> s.replace("Hey", "Yo"));
result = utils.waitForNextCompletion();
Assertions.assertEquals(1, result.getTotalTestsPassed());
Assertions.assertEquals(0, result.getTotalTestsFailed());
}
}