| 179 | |
| 180 | #[test] |
| 181 | fn receipt_roundtrip() { |
| 182 | let receipt = Receipt::new( |
| 183 | "opencode", |
| 184 | "1.0.0", |
| 185 | "0.11.1", |
| 186 | "/tmp/pkg", |
| 187 | vec![ReceiptFile { |
| 188 | dst: PathBuf::from("/home/u/.config/opencode/agents/atomic.md"), |
| 189 | blake3: "abc123".to_string(), |
| 190 | }], |
| 191 | vec![ReceiptSettings { |
| 192 | target: PathBuf::from("/home/u/.config/opencode/opencode.json"), |
| 193 | hooks_key: "hooks".to_string(), |
| 194 | command_prefix: "atomic agent hooks opencode".to_string(), |
| 195 | }], |
| 196 | ); |
| 197 | let json = serde_json::to_string_pretty(&receipt).unwrap(); |
| 198 | let back: Receipt = serde_json::from_str(&json).unwrap(); |
| 199 | assert_eq!(back.agent, "opencode"); |
| 200 | assert_eq!(back.schema, RECEIPT_SCHEMA); |
| 201 | assert_eq!(back.files.len(), 1); |
| 202 | assert_eq!(back.settings.len(), 1); |
| 203 | assert_eq!( |
| 204 | back.recorded_hash(Path::new("/home/u/.config/opencode/agents/atomic.md")), |
| 205 | Some("abc123") |
| 206 | ); |
| 207 | assert_eq!(back.recorded_hash(Path::new("/elsewhere")), None); |
| 208 | } |
| 209 | |
| 210 | #[test] |
| 211 | fn receipt_without_settings_deserializes() { |