This repository was archived by the owner on Jan 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package svs.doido.mongo; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.kubernetes.client.KubernetesTestServer; | ||
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.AfterEach; | ||
import jakarta.inject.Inject; | ||
|
||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.server.mock.KubernetesServer; | ||
import io.fabric8.kubernetes.api.model.Namespace; | ||
import io.fabric8.kubernetes.api.model.NamespaceBuilder; | ||
import io.fabric8.kubernetes.api.model.ConfigMap; | ||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder; | ||
|
||
import java.lang.HashMap; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
|
||
|
||
|
||
@WithKubernetesTestServer | ||
@QuarkusTest | ||
class ConfigmapApiTest { | ||
|
||
@KubernetesTestServer | ||
KubernetesServer mockServer; | ||
@Inject | ||
KubernetesClient client; | ||
|
||
@BeforeEach | ||
public void before() { | ||
final Namespace namespace1 = new NamespaceBuilder().withNewMetadata().withName("namespaceA").and().build(); | ||
final ConfigMap cfgTest = new ConfigMapBuilder().withNewMetadata().withName("test").withNamespace("namespaceA").and().build(); | ||
final HashMap<String,String> data = new HashMap<String,String>(); | ||
data.put("uri","http://www.test.de"); | ||
cfgTest.setData(data); | ||
|
||
// Set up Kubernetes so that our "pretend" pods namespaces created | ||
client.namespaces().resource(namespace1).create(); | ||
client.configmaps().resource(cfgTest).create(); | ||
} | ||
|
||
@AfterEach | ||
public void after() { | ||
final Namespace namespace1 = new NamespaceBuilder().withNewMetadata().withName("namespaceA").and().build(); | ||
|
||
// Set up Kubernetes so that our "pretend" namespaces are deleted | ||
client.namespaces().resource(namespace1).delete(); | ||
} | ||
|
||
|
||
@Test | ||
void testInteractionWithAPIServerForConfigmaps() { | ||
given() | ||
.when().get("/configmap/namespaceA/test") | ||
.then() | ||
.statusCode(200) | ||
.body("size()", is(2)); | ||
} | ||
|
||
} |