Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenShiftClientProducer tests #35650

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.quarkus.openshift.client.deployment;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.openshift.client.OpenShiftClient;
import io.quarkus.test.QuarkusUnitTest;

public class BeanDefaultsTest {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.overrideConfigKey("quarkus.kubernetes-client.devservices.enabled", "false");

@Inject
KubernetesClient kubernetesClient;

@Inject
OpenShiftClient openShiftClient;

@Test
public void openShiftClientIsInstantiated() {
assertNotNull(openShiftClient);
}

@Test
public void kubernetesClientIsInstantiatedAsOpenShiftClient() {
assertNotNull(kubernetesClient);
assertTrue(kubernetesClient instanceof OpenShiftClient);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.quarkus.openshift.client.deployment;

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

import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.openshift.client.OpenShiftClient;
import io.quarkus.test.QuarkusUnitTest;

public class BeanOverridesTest {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.overrideConfigKey("quarkus.kubernetes-client.devservices.enabled", "false");

@Inject
KubernetesClient kubernetesClient;

@Inject
OpenShiftClient openShiftClient;

@Test
public void openShiftClientCanBeOverridden() {
assertEquals("https://example.com/overridden/", openShiftClient.getConfiguration().getMasterUrl());
}

@Test
public void kubernetesClientCanIsOpenShiftInstance() {
assertEquals("https://example.com/overridden/", kubernetesClient.getConfiguration().getMasterUrl());
}

@Singleton
public static class BeanOverridesConfig {
@Produces
public OpenShiftClient openShiftClient() {
return new KubernetesClientBuilder()
.withConfig(new ConfigBuilder(Config.empty())
.withMasterUrl("https://example.com/overridden/")
.build())
.build().adapt(OpenShiftClient.class);
}
}
}