ErrorsConfiguration · rule
configuration.test_value_missing
A test reaches code that reads a setting, and the setting has no value for tests to use.
Area 10, Configuration; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
A test never reads your machine's environment, so it gives the same
answer on every machine. Each setting gets its value in a test from
config.jadpo instead: its test: value, or else its default:. A
setting with neither has nothing for the test to read, so the test could
not run.
Only a secret is different. A test run makes up a throwaway value for each secret, because secrets never appear in test code.
What it looks like
main.jadpo:
type Greeting = Text { max_length: 80}config { greeting: Greeting}function hello() -> Greeting { return config.greeting}test "the greeting is read" { assert hello() == "hello"}
error config.greeting has no value in tests
--> main.jadpo:10:12
|10 | return config.greeting | ^^^^^^^^^^^^^^^ no `test:` or `default:`
- reason
- The test "the greeting is read" reaches this read. A test reads each setting's
test:value, or itsdefault:, andgreetinghas neither; only a secret is made up for a run, andgreetingisn't one. - next
- Give
greetingatest:value, or adefault:, inconfig.jadpo(agent) - rule
- configuration.
test_ value_ missing - help
- https://jadpo.
dev/docs/errors/configuration. test_ value_ missing
(agent) at the end of the next: line means your coding agent can make
the fix itself.
How to fix it
If every test may read the same value, give the setting a test:
value:
greeting: Greeting { test: "hello" }
Every test now reads "hello" for config.greeting. Production still
needs the value set, because a test: value is read only by tests.
If the app should fall back to a value when none is set, give the
setting a default::
greeting: Greeting { default: "hello" }
Tests read "hello", and so does every deployment that doesn't set the
setting.
A single test can instead give the value in its own config: block
(Configuration in tests).
Every other test that reaches config.greeting then needs one too, so a
test: value is usually the simpler fix.
Related
Markdown for agents: /docs/errors/configuration.test_value_missing.md.Built from Jadpo main at aee2e8f.