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

Validating file size via inequality #661

Closed
benmangold opened this issue Dec 9, 2020 · 3 comments
Closed

Validating file size via inequality #661

benmangold opened this issue Dec 9, 2020 · 3 comments

Comments

@benmangold
Copy link

benmangold commented Dec 9, 2020

Describe the feature:

Currently we can validate a file's size via an = N comparison. This request is for validating a file's size via inequalities: > N or < N.

Describe the solution you'd like

I'm imaginging new options such as file: /foo/bar: size_above: 100 or file: /foo/bar: size_below: 100. Implementation-wise I think this is the simplest way to go.

Allowing one to pass an inequality to file: /foo/bar: size: like file: /foo/bar: size: '> 100' is another alternative, but would be more complex.

Describe alternatives you've considered

I'm sure there is a bash command which could be run to validate file size like this, very open to suggestions. I'm also interested in contributing the change if approved. Thanks!

@aelsabbahy
Copy link
Member

You should be able to leverage Advanced Matchers to do what you want.

Example:

file:
  /foo/bar:
    exists: true
    size:
      and:
        - le: 999999999
        - ge: 5

@benmangold
Copy link
Author

Awesome! Thanks for the prompt reply. Closing this issue.

@aelsabbahy
Copy link
Member

No problem, thanks for using goss and providing feedback!

On a related note to this.. I'm hoping within a month or two to release a major enhancement to the goss matches, see:
#576

and Examples: https://github.com/aelsabbahy/goss/blob/add_transforms/examples/goss_awesome_gomega.yaml

Basically, being able to extract JSON and the ability to do numeric tests on strings, so "45" < 50 and "this nested JSON object's value is < 25" type tests.

Any feedback on that PR would be greatly appreciated.

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

No branches or pull requests

2 participants