|
5 | 5 | use rstest::rstest;
|
6 | 6 | use spk_schema::foundation::name::OptName;
|
7 | 7 | use spk_schema::foundation::option_map::OptionMap;
|
| 8 | +use spk_schema::ident::VarRequest; |
| 9 | +use spk_schema::option_map::HOST_OPTIONS; |
8 | 10 |
|
9 | 11 | #[rstest]
|
10 | 12 | #[case(&["hello:world"], &[("hello", "world")])]
|
@@ -33,3 +35,50 @@ fn test_option_flags_parsing(#[case] args: &[&str], #[case] expected: &[(&str, &
|
33 | 35 | .collect();
|
34 | 36 | assert_eq!(actual, expected);
|
35 | 37 | }
|
| 38 | + |
| 39 | +#[rstest] |
| 40 | +#[case::no_host_true(true)] |
| 41 | +#[case::no_host_false(false)] |
| 42 | +#[tokio::test] |
| 43 | +async fn test_get_solver_with_host_options(#[case] no_host: bool) { |
| 44 | + // Test the get_solver() method adds the host options to the solver |
| 45 | + // correctly. |
| 46 | + |
| 47 | + let options_flags = crate::flags::Options { |
| 48 | + options: Vec::new(), |
| 49 | + no_host, |
| 50 | + }; |
| 51 | + |
| 52 | + let solver_flags = crate::flags::Solver { |
| 53 | + repos: crate::flags::Repositories { |
| 54 | + local_repo_only: false, |
| 55 | + no_local_repo: false, |
| 56 | + enable_repo: Default::default(), |
| 57 | + disable_repo: Default::default(), |
| 58 | + when: None, |
| 59 | + legacy_spk_version_tags: false, |
| 60 | + }, |
| 61 | + allow_builds: false, |
| 62 | + check_impossible_initial: false, |
| 63 | + check_impossible_validation: false, |
| 64 | + check_impossible_builds: false, |
| 65 | + check_impossible_all: false, |
| 66 | + }; |
| 67 | + |
| 68 | + let solver = solver_flags.get_solver(&options_flags).await.unwrap(); |
| 69 | + let initial_state = solver.get_initial_state(); |
| 70 | + |
| 71 | + assert!( |
| 72 | + !HOST_OPTIONS.get().unwrap().is_empty(), |
| 73 | + "HOST_OPTIONS must not be empty for this test to be meaningful" |
| 74 | + ); |
| 75 | + |
| 76 | + for (name, value) in HOST_OPTIONS.get().unwrap() { |
| 77 | + let var_request = VarRequest::new_with_value(name, value); |
| 78 | + if no_host { |
| 79 | + assert!(!initial_state.contains_var_request(&var_request)); |
| 80 | + } else { |
| 81 | + assert!(initial_state.contains_var_request(&var_request)); |
| 82 | + } |
| 83 | + } |
| 84 | +} |
0 commit comments