use of io.stackgres.common.crd.sgcluster.StackGresClusterList in project stackgres by ongres.
the class DependenciesValidatorTest method givenAReviewDelete_itShouldFailIfAClusterDependsOnIt.
@Test
public void givenAReviewDelete_itShouldFailIfAClusterDependsOnIt() {
T review = getReview_givenAReviewDelete_itShouldFailIfAClusterDependsOnIt();
StackGresClusterList clusterList = JsonUtil.readFromJson("stackgres_cluster/list.json", StackGresClusterList.class);
when(clusterScanner.findResources(review.getRequest().getNamespace())).thenReturn(Optional.of(clusterList.getItems()));
ValidationFailed ex = ValidationUtils.assertErrorType(ErrorType.FORBIDDEN_CR_DELETION, () -> validator.validate(review));
assertEquals("Can't delete " + review.getRequest().getResource().getResource() + "." + review.getRequest().getKind().getGroup() + " " + review.getRequest().getName() + " because the " + CustomResource.getCRDName(StackGresCluster.class) + " " + clusterList.getItems().get(0).getMetadata().getName() + " depends on it", ex.getResult().getMessage());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterList in project stackgres by ongres.
the class DependenciesValidatorTest method givenAReviewDelete_itShouldNotFailIfNoClusterDependsOnIt.
@Test
public void givenAReviewDelete_itShouldNotFailIfNoClusterDependsOnIt() throws ValidationFailed {
T review = getReview_givenAReviewDelete_itShouldNotFailIfNoClusterDependsOnIt();
StackGresClusterList clusterList = JsonUtil.readFromJson("stackgres_cluster/list.json", StackGresClusterList.class);
clusterList.getItems().stream().forEach(this::makeClusterNotDependant);
when(clusterScanner.findResources(review.getRequest().getNamespace())).thenReturn(Optional.of(clusterList.getItems()));
validator.validate(review);
verify(clusterScanner, never()).findResources();
verify(clusterScanner).findResources(review.getRequest().getNamespace());
}
Aggregations