| 695 | |
| 696 | #[test] |
| 697 | fn test_multi_condition() { |
| 698 | let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); |
| 699 | path.push("resources/fixtures/repo.json"); |
| 700 | let json_str = fs::read_to_string(path).unwrap(); |
| 701 | let repo = load_json(&json_str); |
| 702 | assert!(repo.is_ok()); |
| 703 | let repo = repo.unwrap(); |
| 704 | |
| 705 | let user = FPUser::new().with("city", "1").with("os", "linux"); |
| 706 | let toggle = repo.toggles.get("multi_condition_toggle").unwrap(); |
| 707 | let r = toggle.eval(&user, &repo.segments, &repo.toggles, false, MAX_DEEP, None); |
| 708 | let r = r.value.unwrap(); |
| 709 | let r = r.as_object().unwrap(); |
| 710 | assert!(r.get("variation_0").is_some()); |
| 711 | |
| 712 | let user = FPUser::new().with("os", "linux"); |
| 713 | let toggle = repo.toggles.get("multi_condition_toggle").unwrap(); |
| 714 | let r = toggle.eval(&user, &repo.segments, &repo.toggles, false, MAX_DEEP, None); |
| 715 | assert!(r.reason.starts_with("default")); |
| 716 | |
| 717 | let user = FPUser::new().with("city", "1"); |
| 718 | let toggle = repo.toggles.get("multi_condition_toggle").unwrap(); |
| 719 | let r = toggle.eval(&user, &repo.segments, &repo.toggles, false, MAX_DEEP, None); |
| 720 | assert!(r.reason.starts_with("default")); |
| 721 | } |
| 722 | |
| 723 | #[test] |
| 724 | fn test_distribution_condition() { |