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

Conditional assertions #203

Open
jankoada opened this issue Aug 30, 2023 · 2 comments
Open

Conditional assertions #203

jankoada opened this issue Aug 30, 2023 · 2 comments
Assignees
Labels

Comments

@jankoada
Copy link

Hi, thanks for this great project. Is there a way to specify conditional assertions that if an annotation exists, it conforms to some regex?

I have this test:

suite: test service
templates:
  - service.yaml
tests:
  - it: DNS hostname is within length limit
    asserts:
      - matchRegex:
          path: metadata.annotations["external-dns.alpha.kubernetes.io/hostname"]
          pattern: "^(.{3,52}$"

But if annotation is not set, the test fails with unknown path metadata.annotations["external-dns.alpha.kubernetes.io/hostname"]. But I want the scenario of annotation not set to be valid as well.

I did not find anything in the documentation on this topic, is it even supported?

@quintush
Copy link
Contributor

Hello @jankoada,

Thanks for the suggestion.
Will look into it.

Greetings,
@quintush

@avaakash
Copy link

@quintush I am wondering if we can add a flag in the test cases to make them optional, as in if they fail we throw a warning but the overall test suite doesn't fail because of it. If this seems like a possible way to do it, I can take up the work on this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants