Skip to content

Commit

Permalink
chore(tests): fix failing tests
Browse files Browse the repository at this point in the history
the check of API Groups was causing an extra REST request which broke various mock server tests
  • Loading branch information
jstrachan committed Jul 3, 2017
1 parent 204c914 commit 3e1f8b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public String getOapiVersion() {
return oapiVersion;
}

@JsonProperty("apiGroupVersion")
@JsonIgnore
public String getApiGroupVersion() {
return apiGroupVersion;
}
Expand All @@ -180,14 +180,6 @@ public void setOapiVersion(String oapiVersion) {
this.oapiVersion = oapiVersion;
}

/**
* Returns true if this resource is an API Group using API Group based versions
*/
@JsonIgnore
public boolean isApiGroup() {
return apiGroupVersion != null && apiGroupVersion.length() > 0;
}

@JsonProperty("openShiftUrl")
public String getOpenShiftUrl() {
return openShiftUrl;
Expand All @@ -202,7 +194,7 @@ public long getBuildTimeout() {
return buildTimeout;
}

public <L extends KubernetesResourceList> void setBuildTimeout(long buildTimeout) {
public void setBuildTimeout(long buildTimeout) {
this.buildTimeout = buildTimeout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.mockwebserver.dsl.MockServerExpectation;
import io.fabric8.openshift.client.NamespacedOpenShiftClient;
import io.fabric8.openshift.client.OpenshiftAdapterSupport;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.rules.ExternalResource;

Expand All @@ -40,6 +41,15 @@ public KubernetesClient getKubernetesClient() {
}

public NamespacedOpenShiftClient getOpenshiftClient() {
if (!new OpenshiftAdapterSupport().isAdaptable(client)) {
throw new IllegalArgumentException("Client does not support OpenShift!");
}
// now lets remove the REST request to access the apis to avoid breaking tests :)
try {
mock.takeRequest();
} catch (InterruptedException e) {
// ignore
}
return client;
}

Expand Down

0 comments on commit 3e1f8b6

Please sign in to comment.