-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support to variables inside test cases #50
Comments
Thanks for filing this. Environment variables seems not extensible, how about support template via something like https://docs.rs/minijinja/latest/minijinja/ ? By using those template engine, we can not only do variable replacement, but also other advance tricks like {% for user in users %}
<li>{{ user.name }}</li>
{% endfor %} |
nice reference 👍 From my perspective template replacing is a little different from env variable. Template are something like "repeat and fill the blank with the given value set", while env is only for variable replacement. Template usually have a fixed value set that is written in the file, like Both template and env are useful, I'll file a ticket requests for template interceptor |
I found the template engine supports the function call, which makes things simple. We can add built-in functions, like e.g., Assuming we have a template like |
FYI, sqlness uses the |
Since they are overlapping in function, I prefer we choose one solution and stick with it. |
There are some differences. Let's assume this ticket requests
-- SQLNESS ENV S3_SECRET
CREATE TABLE t (c PRIMARY KEY) with (STORATE=$S3_SECRET); and the result file env_example.result
-- SQLNESS TEMPLATE i=0..100
INSERT INTO t (c) VALUES {{i}}; and the result file template_example.result
You can see that |
This sound a good user case for env, but I think we can also avoid render input SQL when using template.
By stick with one solution, it means:
|
This extra render option looks good to me. Maybe we should mention it in #51. The one critical divergence is, the value referred in |
make sense to me |
Both env and template are used to replace text, so they are the same in real effect, doesn't it?
Even in template intercepter, some value will be read from environment variables when populate template. Besides I will open a PR to make interceptor configurable, and users can add their own intercepter, such as |
This looks good. I think we also need to expose the definition of interceptor trait to allow users to add their own interceptors. This can be configured like session context, user can choose which interceptor to active. |
OK, I will first open a PR to add this. |
Completed in #56 |
Describe This Problem
We have a scenario like this:
It's trying to create an external file table from an absolute path, specifying the absolute path in the local development environment is acceptable. However, Using the same absolute path in other environments (i.g., CI) will be problematic.
Proposal
Therefore, we can treat the test cases as templates and inject the environment variables at runtime.
I propose a template syntax:
it will replace all
{{\$.*}}
withEnv(.*)
in a test case file.Additional Context
No response
The text was updated successfully, but these errors were encountered: