Skip to content

Commit

Permalink
feat: #1209 Adding test for HTTPEndpoint in testcontainers module
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
  • Loading branch information
lbroudoux committed Feb 4, 2025
1 parent 03d795f commit 64987a1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public Set<Subscription> getSubscriptions() {
return subscriptions;
}

public Set<HttpEndpoint> getHttpEndpoints() {
return httpEndpoints;
}

public DaprContainer withAppPort(Integer port) {
this.appPort = port;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.dapr.testcontainers.converter;

import io.dapr.testcontainers.DaprContainer;
import io.dapr.testcontainers.HttpEndpoint;
import org.junit.jupiter.api.Test;
import org.yaml.snakeyaml.Yaml;

import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;

class HttpEndpointYamlConverterTest {
private final Yaml MAPPER = YamlMapperFactory.create();

private final HttpEndpointYamlConverter converter = new HttpEndpointYamlConverter(MAPPER);

@Test
void testHttpEndpointToYaml() {
DaprContainer dapr = new DaprContainer("daprio/daprd")
.withAppName("dapr-app")
.withAppPort(8081)
.withHttpEndpoint(new HttpEndpoint("my-endpoint", "http://localhost:8080"))
.withAppChannelAddress("host.testcontainers.internal");

Set<HttpEndpoint> endpoints = dapr.getHttpEndpoints();
assertEquals(1, endpoints.size());

HttpEndpoint endpoint = endpoints.iterator().next();
String endpointYaml = converter.convert(endpoint);
String expectedEndpointYaml =
"apiVersion: dapr.io/v1alpha1\n"
+ "kind: HTTPEndpoint\n"
+ "metadata:\n"
+ " name: my-endpoint\n"
+ "spec:\n"
+ " baseUrl: http://localhost:8080\n";

assertEquals(expectedEndpointYaml, endpointYaml);
}
}

0 comments on commit 64987a1

Please sign in to comment.