Originally created by @lucsoft on GitHub (May 5, 2025).
i would to mock read's like read("env:MY_CUSTOM_ENV") for a specific test case/(or test file at least)
Context: I have a Global Config object which reads env variables and i would like to define them in a test file.
Mocking Resources could be a way i think
Originally created by @lucsoft on GitHub (May 5, 2025).
i would to mock read's like `read("env:MY_CUSTOM_ENV")` for a specific test case/(or test file at least)
Context: I have a Global Config object which reads env variables and i would like to define them in a test file.
Mocking Resources could be a way i think
@StefMa commented on GitHub (May 5, 2025):
You might wanna check this discussion that provides a solution: https://github.com/apple/pkl/discussions/1032
@StefMa i don't think that it actually solves my issue as this is local mocking and not global
i have a global config file, and i want to test a specific file which imports the config file
i don't think i can currently mock the response of that "internal" import of that config file
@lucsoft commented on GitHub (May 6, 2025):
@StefMa i don't think that it actually solves my issue as this is local mocking and not global
i have a global config file, and i want to test a specific file which imports the config file
i don't think i can currently mock the response of that "internal" import of that config file
I have the same advice that I did in the discussion that @StefMa linked to.
The best way to stub out that value is to expose it as an API, and replace it in your tests.
If you really want to, you can set env vars when running pkl test, e.g. run shell command FOO=1 pkl test
@bioball commented on GitHub (May 7, 2025):
I have the same advice that I did in the discussion that @StefMa linked to.
The best way to stub out that value is to expose it as an API, and replace it in your tests.
If you really want to, you can set env vars when running `pkl test`, e.g. run shell command `FOO=1 pkl test`
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @lucsoft on GitHub (May 5, 2025).
i would to mock read's like
read("env:MY_CUSTOM_ENV")for a specific test case/(or test file at least)Context: I have a Global Config object which reads env variables and i would like to define them in a test file.
Mocking Resources could be a way i think
@StefMa commented on GitHub (May 5, 2025):
You might wanna check this discussion that provides a solution: https://github.com/apple/pkl/discussions/1032
@lucsoft commented on GitHub (May 6, 2025):
@StefMa i don't think that it actually solves my issue as this is local mocking and not global
i have a global config file, and i want to test a specific file which imports the config file
i don't think i can currently mock the response of that "internal" import of that config file
@bioball commented on GitHub (May 7, 2025):
I have the same advice that I did in the discussion that @StefMa linked to.
The best way to stub out that value is to expose it as an API, and replace it in your tests.
If you really want to, you can set env vars when running
pkl test, e.g. run shell commandFOO=1 pkl test