Skip to content

Commit cd89dbf

Browse files
committed
adding tests for null state store
Signed-off-by: salaboy <Salaboy@gmail.com>
1 parent dcdfb56 commit cd89dbf

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

testcontainers-dapr/src/main/java/io/dapr/testcontainers/WorkflowDashboardContainer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ public WorkflowDashboardContainer(String image) {
6565
@Override
6666
protected void configure() {
6767
super.configure();
68-
if (stateStoreComponent != null) {
69-
String componentYaml = COMPONENT_CONVERTER.convert(stateStoreComponent);
70-
withCopyToContainer(Transferable.of(componentYaml), "/app/components/" + stateStoreComponent.getName() + ".yaml");
71-
withEnv("COMPONENT_FILE", "/app/components/" + stateStoreComponent.getName() + ".yaml");
68+
if (stateStoreComponent == null) {
69+
throw new IllegalStateException("State store component cannot be null");
7270
}
7371

72+
String componentYaml = COMPONENT_CONVERTER.convert(stateStoreComponent);
73+
withCopyToContainer(Transferable.of(componentYaml), "/app/components/" + stateStoreComponent.getName() + ".yaml");
74+
withEnv("COMPONENT_FILE", "/app/components/" + stateStoreComponent.getName() + ".yaml");
75+
7476
}
7577

7678
public static DockerImageName getDefaultImageName() {

testcontainers-dapr/src/test/java/io/dapr/testcontainers/DaprWorkflowDashboardTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ public void dashboardTest() {
3838
assertEquals(WorkflowDashboardContainer.DEFAULT_IMAGE_NAME, dashboard.getDefaultImageName());
3939
assertEquals(8080, dashboard.getExposedPorts().get(0));
4040
assertEquals(stateStoreComponent, dashboard.getStateStoreComponent());
41+
assertEquals("/app/components/kvstore.yaml", dashboard.getEnvMap().get("COMPONENT_FILE"));
4142
}
4243
}
44+
45+
@Test
46+
public void dashboardNoStateStoreTest() {
47+
Exception expectedException = null;
48+
try{
49+
WorkflowDashboardContainer dashboard =
50+
new WorkflowDashboardContainer(WorkflowDashboardContainer.DEFAULT_IMAGE_NAME);
51+
dashboard.configure();
52+
} catch(IllegalStateException ex){
53+
expectedException = ex;
54+
}
55+
assertNotNull(expectedException);
56+
}
4357
}

0 commit comments

Comments
 (0)