| 1714 | |
| 1715 | #[test] |
| 1716 | fn test_json_status_escapes_paths() { |
| 1717 | let mut status = RepositoryStatus::new("dev".to_string(), None); |
| 1718 | status.add_entry(FileStatusEntry::new( |
| 1719 | PathBuf::from("line\nbreak.txt"), |
| 1720 | FileStatus::Untracked, |
| 1721 | )); |
| 1722 | |
| 1723 | let output = JsonStatus::new(&status, std::path::Path::new("/workspace")); |
| 1724 | let json = serde_json::to_string(&output).unwrap(); |
| 1725 | |
| 1726 | assert!(json.contains("line\\nbreak.txt")); |
| 1727 | assert_eq!( |
| 1728 | serde_json::from_str::<serde_json::Value>(&json).unwrap()["entries"][0]["path"], |
| 1729 | "line\nbreak.txt" |
| 1730 | ); |
| 1731 | } |
| 1732 | |
| 1733 | #[test] |
| 1734 | fn test_json_and_short_are_mutually_exclusive() { |