mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
test(config): legacy config with unknown field must load (red)
A config without a `version:` is the legacy/lenient schema (RFC-002): an unrecognized top-level key must be tolerated, not rejected. This test pins that contract and fails today because `deny_unknown_fields` is applied unconditionally (struct-wide), so the `version` discriminator does not actually gate strictness. Intentionally red — goes green in the next commit, which gates unknown-field strictness on `version`.
This commit is contained in:
parent
f454de9906
commit
925ddb7c7f
1 changed files with 16 additions and 0 deletions
|
|
@ -1279,6 +1279,22 @@ cli:
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_config_tolerates_unknown_fields() {
|
||||
// No `version:` ⇒ legacy schema: an unrecognized key is tolerated, not
|
||||
// rejected (RFC-002: a missing `version:` is the lenient legacy shape).
|
||||
// Pins the contract that `version` — not an unconditional struct
|
||||
// attribute — gates strictness; a `version: 1` config rejects the same
|
||||
// key (see `version_one_rejects_unknown_nested_field`). A top-level key
|
||||
// is used deliberately: that is the level a struct-wide
|
||||
// `deny_unknown_fields` catches today, so this reproduces the bug.
|
||||
let config = load_yaml(
|
||||
"graphs:\n local:\n uri: ./demo.omni\n\
|
||||
future_top_level_key: whatever\ncli:\n graph: local\n",
|
||||
);
|
||||
assert_eq!(config.cli_graph_name(), Some("local"));
|
||||
}
|
||||
|
||||
fn load_yaml(yaml: &str) -> super::OmnigraphConfig {
|
||||
let temp = tempdir().unwrap();
|
||||
fs::write(temp.path().join("omnigraph.yaml"), yaml).unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue