| 1054 | |
| 1055 | #[test] |
| 1056 | fn test_json_status_escapes_paths() { |
| 1057 | let mut status = RepositoryStatus::new("dev".to_string(), None); |
| 1058 | status.add_entry(FileStatusEntry::new( |
| 1059 | PathBuf::from("line\nbreak.txt"), |
| 1060 | FileStatus::Untracked, |
| 1061 | )); |
| 1062 | |
| 1063 | let output = JsonStatus::new(&status, std::path::Path::new("/workspace")); |
| 1064 | let json = serde_json::to_string(&output).unwrap(); |
| 1065 | |
| 1066 | assert!(json.contains("line\\nbreak.txt")); |
| 1067 | assert_eq!( |
| 1068 | serde_json::from_str::<serde_json::Value>(&json).unwrap()["entries"][0]["path"], |
| 1069 | "line\nbreak.txt" |
| 1070 | ); |
| 1071 | } |
| 1072 | |
| 1073 | #[test] |
| 1074 | fn test_json_and_short_are_mutually_exclusive() { |