gdt-dev / gdt

Go Declarative Testing
Apache License 2.0
4 stars 2 forks source link

feature: skip-if conditional scenario skip #5

Closed jaypipes closed 1 year ago

jaypipes commented 1 year ago

Adds support for skip-if collection of evaluable conditions for a scenario. If any of these conditions fails, the test will be skipped.

SkipIf contains a list of evaluable conditions that must evaluate successfully before the scenario's tests are executed. This allows test authors to specify "pre-flight checks" that should pass before attempting any of the actions in the scenario's tests.

For example, let's assume you have a gdt-kube scenario that looks like this:

tests:
 - kube.create: manifests/nginx-deployment.yaml
 - kube:
   get: deployments/nginx
   assert:
     matches:
       status:
         readyReplicas: 2
 - kube.delete: deployments/nginx

If you execute the above test and there is already an 'nginx' deployment, the kube.create test will fail. To prevent the scenario from proceeding with the tests if an 'nginx' deployment already exists, you could add the following

skip-if:
 - kube.get: deployments/nginx
tests:
 - kube.create: manifests/nginx-deployment.yaml
 - kube:
   get: deployments/nginx
   assert:
     matches:
       status:
         readyReplicas: 2
 - kube.delete: deployments/nginx

With the above, if an 'nginx' deployment exists already, the scenario will skip all the tests.