| 626 | } |
| 627 | |
| 628 | fn assert_valid_config(path: &Path) -> Result<(), String> { |
| 629 | let config = Config::from_file(path) |
| 630 | .map_err(|e| format!("expected valid config {}: {e}", path.display()))?; |
| 631 | let snapshot = ConfigSnapshot { |
| 632 | derived: DerivedValues { |
| 633 | listen_addr: config.listen_addr(), |
| 634 | openai_upstream_url: config.upstream_url(Provider::Openai), |
| 635 | anthropic_upstream_url: config.upstream_url(Provider::Anthropic), |
| 636 | key_map: config.key_map(), |
| 637 | }, |
| 638 | config, |
| 639 | }; |
| 640 | let name = snapshot_name(path)?; |
| 641 | insta::with_settings!({ |
| 642 | snapshot_path => "../tests/snapshots", |
| 643 | prepend_module_to_snapshot => false, |
| 644 | }, { |
| 645 | insta::assert_yaml_snapshot!(name, snapshot); |
| 646 | }); |
| 647 | Ok(()) |
| 648 | } |
| 649 | |
| 650 | fn assert_invalid_config(path: &Path) -> Result<(), String> { |
| 651 | let err = Config::from_file(path).expect_err(&format!( |