Search in sources :

Example 16 with StackGresDbOpsReview

use of io.stackgres.operator.common.StackGresDbOpsReview in project stackgres by ongres.

the class DbOpsConstraintValidatorTest method wrongRunAt_shouldFail.

@Test
void wrongRunAt_shouldFail() {
    StackGresDbOpsReview review = getValidReview();
    review.getRequest().getObject().getSpec().setRunAt("2018-01-01 01:02:03");
    checkErrorCause(StackGresDbOpsSpec.class, "spec.runAt", "spec.isRunAtValid", review, AssertTrue.class);
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 17 with StackGresDbOpsReview

use of io.stackgres.operator.common.StackGresDbOpsReview in project stackgres by ongres.

the class DbOpsConstraintValidatorTest method nullSgCluster_shouldFail.

@Test
void nullSgCluster_shouldFail() {
    StackGresDbOpsReview review = getValidReview();
    review.getRequest().getObject().getSpec().setSgCluster(null);
    checkErrorCause(StackGresDbOpsSpec.class, "spec.sgCluster", review, NotNull.class);
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 18 with StackGresDbOpsReview

use of io.stackgres.operator.common.StackGresDbOpsReview in project stackgres by ongres.

the class DbOpsConstraintValidatorTest method invalidDuration_shouldFailWithMessage.

@Test
void invalidDuration_shouldFailWithMessage() {
    StackGresDbOpsReview review = getValidReview();
    review.getRequest().getObject().getSpec().getBenchmark().getPgbench().setDuration("P5M");
    ValidationFailed assertThrows = assertThrows(ValidationFailed.class, () -> validator.validate(review));
    assertEquals("SGDbOps has invalid properties. " + "duration must be positive and in ISO 8601 duration format: `PnDTnHnMn.nS`.", assertThrows.getMessage());
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) ValidationFailed(io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 19 with StackGresDbOpsReview

use of io.stackgres.operator.common.StackGresDbOpsReview in project stackgres by ongres.

the class DbOpsConstraintValidatorTest method nullSpec_shouldFail.

@Test
void nullSpec_shouldFail() {
    StackGresDbOpsReview review = getValidReview();
    review.getRequest().getObject().setSpec(null);
    checkNotNullErrorCause(StackGresDbOps.class, "spec", review);
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview) Test(org.junit.jupiter.api.Test) ConstraintValidationTest(io.stackgres.operator.validation.ConstraintValidationTest)

Example 20 with StackGresDbOpsReview

use of io.stackgres.operator.common.StackGresDbOpsReview in project stackgres by ongres.

the class DbOpsConstraintValidatorTest method getInvalidReview.

@Override
protected StackGresDbOpsReview getInvalidReview() {
    final StackGresDbOpsReview review = JsonUtil.readFromJson("dbops_allow_requests/valid_pgbench_creation.json", StackGresDbOpsReview.class);
    review.getRequest().getObject().setSpec(null);
    return review;
}
Also used : StackGresDbOpsReview(io.stackgres.operator.common.StackGresDbOpsReview)

Aggregations

StackGresDbOpsReview (io.stackgres.operator.common.StackGresDbOpsReview)28 Test (org.junit.jupiter.api.Test)24 ConstraintValidationTest (io.stackgres.operator.validation.ConstraintValidationTest)22 ValidationFailed (io.stackgres.operatorframework.admissionwebhook.validating.ValidationFailed)2