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

Random string #35

Open
meiremans opened this issue Dec 13, 2018 · 6 comments
Open

Random string #35

meiremans opened this issue Dec 13, 2018 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@meiremans
Copy link
Contributor

Hi

Is there a way to generate a random string and use that string during the whole test run?

with kind regards

@aviaviavi
Copy link
Owner

Hi there!

Since curl runnings loads environment variables at the beginning of the test suite, using the ${RANDOM} environment variable will generate a random number, which you can use as a string in your tests. Will that work for you?

@aviaviavi
Copy link
Owner

You can also generate your own random strings and set them as environment variables that you reference in your curl-runnings tests. Nothing is built into the spec that has random functionality, but one could certainly be added if there's a good use case

@meiremans
Copy link
Contributor Author

Hi
Thanks for the quick reply. I actually tried something like that but didn't work on first try. I think it was something like ${RANDOM | tr '[0-9]' '[a-zA-Z]'} Anyway, probably my mistake in the syntax and will do it simply with ${RANDOM}.

My use case is this, make a random user, do things with it and set the user on inactive.
As the API doesn't expose a real deletion of the user a second run will make the test fail because he cannot create that user again.

@aviaviavi
Copy link
Owner

aviaviavi commented Dec 13, 2018

Got it. So CR won't evaluate arbitrary bash expressions which is why RANDOM | tr '[0-9]' '[a-zA-Z]' wasn't working. Just environment variables as they are. So yeah for now, just RANDOM, or simply invoke curl runnings with something like USER_ID="$(RANDOM | tr '[0-9]' '[a-zA-Z]')" curl-runnings -f <your_file>

Sounds like having some random string + number generators natively supported by curl-runnings would be useful though, I do agree about that.

(Adding some labels to keep track of this. I think we have both a workaround for now as well as opportunities for curl-runnings to support this in a much more robust way)

@aviaviavi aviaviavi added enhancement New feature or request good first issue Good for newcomers labels Dec 14, 2018
@meiremans
Copy link
Contributor Author

Thank you very much for your quick reply.
I agree a random string and number generator would be useful. but the current workaround works fine for me.

On an other note, I am running this inside a docker container. Would it be useful if I push my dockerfile for other docker users?

@aviaviavi
Copy link
Owner

absolutely! please open a PR whenever you have the chance, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants