Skip to content

Commit 498cfb9

Browse files
committed
UTs fix / mock function.zip introduced
1 parent 3e76a75 commit 498cfb9

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package airhacks;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
6+
public interface FunctionZip {
7+
8+
public static String createEmptyFunctionZip() throws IOException{
9+
var path = Files.createTempDirectory("function");
10+
var functionZip = path.resolve("function.zip");
11+
var existingFile = Files.createFile(functionZip);
12+
System.out.println("existingFile = " + existingFile);
13+
return existingFile.toString();
14+
}
15+
}

cdk/src/test/java/airhacks/alb/boundary/LambdaAlbStackTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
import software.amazon.awscdk.App;
1414

15-
@Disabled("builder is not available yet")
1615
public class LambdaAlbStackTest {
1716
private final static ObjectMapper JSON =
18-
new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
19-
17+
new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
18+
2019
@Test
21-
public void testStack() throws IOException {
20+
@Disabled("builder is not available yet")
21+
public void stack() throws IOException {
2222
App app = new App();
2323
var stack = new LambdaAlbStack(app, "test");
2424

cdk/src/test/java/airhacks/apigateway/boundary/LambdaApiGatewayStackTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.databind.ObjectMapper;
88
import com.fasterxml.jackson.databind.SerializationFeature;
99

10+
import airhacks.FunctionZip;
1011
import airhacks.InfrastructureBuilder;
1112

1213
import org.junit.jupiter.api.Test;
@@ -17,10 +18,12 @@ public class LambdaApiGatewayStackTest {
1718
private final static ObjectMapper JSON = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
1819

1920
@Test
20-
public void testStack() throws IOException {
21+
public void stack() throws IOException {
22+
var mockFunctionZip = FunctionZip.createEmptyFunctionZip();
2123
App app = new App();
2224
var stack = new InfrastructureBuilder(app, "function-url")
2325
.functionName("functionurl-test")
26+
.functionZip(mockFunctionZip)
2427
.apiGatewayBuilder()
2528
.build();
2629

cdk/src/test/java/airhacks/functionurl/boundary/FunctionURLStackTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.databind.ObjectMapper;
88
import com.fasterxml.jackson.databind.SerializationFeature;
99

10+
import airhacks.FunctionZip;
1011
import airhacks.InfrastructureBuilder;
1112

1213
import org.junit.jupiter.api.Test;
@@ -18,12 +19,14 @@ public class FunctionURLStackTest {
1819
private final static ObjectMapper JSON = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
1920

2021
@Test
21-
public void functionURLSynth() throws IOException {
22+
void stack() throws IOException {
23+
var mockFunctionZip = FunctionZip.createEmptyFunctionZip();
2224
App app = new App();
2325
var stack = new InfrastructureBuilder(app, "function-url")
24-
.functionName("functionurl-test")
25-
.functionURLBuilder()
26-
.build();
26+
.functionName("functionurl-test")
27+
.functionZip(mockFunctionZip)
28+
.functionURLBuilder()
29+
.build();
2730

2831
// synthesize the stack to a CloudFormation template
2932
var actual = JSON.valueToTree(app.synth().getStackArtifact(stack.getArtifactId()).getTemplate());

0 commit comments

Comments
 (0)