From 21c0e68ab5e11089ba943a4fd267b5de7d3e9158 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 15 Dec 2022 17:44:09 +0000 Subject: [PATCH] surf: testing an added file Test the serialization of an added file in a Diff. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-surf/t/src/git/diff.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/radicle-surf/t/src/git/diff.rs b/radicle-surf/t/src/git/diff.rs index 9098f06..8de7555 100644 --- a/radicle-surf/t/src/git/diff.rs +++ b/radicle-surf/t/src/git/diff.rs @@ -9,7 +9,6 @@ use radicle_surf::{ EofNewLine, FileDiff, Hunk, - Hunks, Line, Modification, Modified, @@ -152,7 +151,14 @@ fn test_diff_serde() { let diff = Diff { added: vec![ Added { path: Path::new("LICENSE").to_path_buf(), - diff: FileDiff::Plain { hunks: Hunks::default() } + diff: FileDiff::Plain { + hunks: vec![Hunk { + header: Line::from(b"@@ -0,0 +1,1".to_vec()), + lines: vec![ + Addition { line: Line::from(b"MIT".to_vec()), line_no: 1 } + ] + }].into() + } }], deleted: vec![], moved: vec![ Moved { @@ -184,9 +190,17 @@ fn test_diff_serde() { let eof: Option = None; let json = serde_json::json!({ - "added": [{"path": "LICENSE", "diff": { + "added": [{ + "path": "LICENSE", + "diff": { "type": "plain", - "hunks": [] + "hunks": [{ + "header": "@@ -0,0 +1,1", + "lines": [{ + "line": "MIT", + "lineNo": 1, + }] + }] }, }], "deleted": [],