Skip to main content

set_secret

Function set_secret 

Source
pub fn set_secret<T: SecretValue>(
    secret: &Secret<T>,
    value: impl AsRef<[u8]>,
) -> Result<(), Error>
Expand description

Overrides secret with value for the current test only.

Other tests do not see the override, and it is discarded when the test ends. Not supported in system tests (where services read their own values); set test secret values in secrets.test.toml instead.

ⓘ
encore::testing::set_secret(&API_KEY, "test-key")?;
assert_eq!(*API_KEY.value(), "test-key");