@@ -79,6 +79,7 @@ mod tests {
7979
8080 #[ test]
8181 fn test_fs_read_single_line ( ) {
82+ let content = "Hello, world!" ;
8283 let fixture = ToolOperation :: FsRead {
8384 input : forge_domain:: FSRead {
8485 path : "/home/user/test.txt" . to_string ( ) ,
@@ -87,10 +88,11 @@ mod tests {
8788 show_line_numbers : true ,
8889 } ,
8990 output : ReadOutput {
90- content : Content :: File ( "Hello, world!" . to_string ( ) ) ,
91+ content : Content :: file ( content ) ,
9192 start_line : 1 ,
9293 end_line : 1 ,
9394 total_lines : 5 ,
95+ content_hash : crate :: compute_hash ( content) ,
9496 } ,
9597 } ;
9698 let env = fixture_environment ( ) ;
@@ -103,6 +105,7 @@ mod tests {
103105
104106 #[ test]
105107 fn test_fs_read_multiple_lines ( ) {
108+ let content = "Line 1\n Line 2\n Line 3" ;
106109 let fixture = ToolOperation :: FsRead {
107110 input : forge_domain:: FSRead {
108111 path : "/home/user/test.txt" . to_string ( ) ,
@@ -111,10 +114,11 @@ mod tests {
111114 show_line_numbers : true ,
112115 } ,
113116 output : ReadOutput {
114- content : Content :: File ( "Line 1 \n Line 2 \n Line 3" . to_string ( ) ) ,
117+ content : Content :: file ( content ) ,
115118 start_line : 2 ,
116119 end_line : 4 ,
117120 total_lines : 10 ,
121+ content_hash : crate :: compute_hash ( content) ,
118122 } ,
119123 } ;
120124 let env = fixture_environment ( ) ;
@@ -127,16 +131,18 @@ mod tests {
127131
128132 #[ test]
129133 fn test_fs_create_new_file ( ) {
134+ let content = "New file content" ;
130135 let fixture = ToolOperation :: FsCreate {
131136 input : forge_domain:: FSWrite {
132137 path : "/home/user/project/new_file.txt" . to_string ( ) ,
133- content : "New file content" . to_string ( ) ,
138+ content : content. to_string ( ) ,
134139 overwrite : false ,
135140 } ,
136141 output : FsCreateOutput {
137142 path : "/home/user/project/new_file.txt" . to_string ( ) ,
138143 before : None ,
139144 warning : None ,
145+ content_hash : crate :: compute_hash ( content) ,
140146 } ,
141147 } ;
142148 let env = fixture_environment ( ) ;
@@ -149,16 +155,18 @@ mod tests {
149155
150156 #[ test]
151157 fn test_fs_create_overwrite ( ) {
158+ let content = "new content" ;
152159 let fixture = ToolOperation :: FsCreate {
153160 input : forge_domain:: FSWrite {
154161 path : "/home/user/project/existing_file.txt" . to_string ( ) ,
155- content : "new content" . to_string ( ) ,
162+ content : content. to_string ( ) ,
156163 overwrite : true ,
157164 } ,
158165 output : FsCreateOutput {
159166 path : "/home/user/project/existing_file.txt" . to_string ( ) ,
160167 before : Some ( "old content" . to_string ( ) ) ,
161168 warning : None ,
169+ content_hash : crate :: compute_hash ( content) ,
162170 } ,
163171 } ;
164172 let env = fixture_environment ( ) ;
@@ -175,16 +183,18 @@ mod tests {
175183
176184 #[ test]
177185 fn test_fs_create_with_warning ( ) {
186+ let content = "File content" ;
178187 let fixture = ToolOperation :: FsCreate {
179188 input : forge_domain:: FSWrite {
180189 path : "/home/user/project/file.txt" . to_string ( ) ,
181- content : "File content" . to_string ( ) ,
190+ content : content. to_string ( ) ,
182191 overwrite : false ,
183192 } ,
184193 output : FsCreateOutput {
185194 path : "/home/user/project/file.txt" . to_string ( ) ,
186195 before : None ,
187196 warning : Some ( "File created outside project directory" . to_string ( ) ) ,
197+ content_hash : crate :: compute_hash ( content) ,
188198 } ,
189199 } ;
190200 let env = fixture_environment ( ) ;
@@ -293,6 +303,7 @@ mod tests {
293303
294304 #[ test]
295305 fn test_fs_patch_success ( ) {
306+ let after_content = "Hello universe\n This is a test\n New line" ;
296307 let fixture = ToolOperation :: FsPatch {
297308 input : forge_domain:: FSPatch {
298309 path : "/home/user/project/test.txt" . to_string ( ) ,
@@ -303,7 +314,8 @@ mod tests {
303314 output : PatchOutput {
304315 warning : None ,
305316 before : "Hello world\n This is a test" . to_string ( ) ,
306- after : "Hello universe\n This is a test\n New line" . to_string ( ) ,
317+ after : after_content. to_string ( ) ,
318+ content_hash : crate :: compute_hash ( after_content) ,
307319 } ,
308320 } ;
309321 let env = fixture_environment ( ) ;
@@ -314,6 +326,7 @@ mod tests {
314326
315327 #[ test]
316328 fn test_fs_patch_with_warning ( ) {
329+ let after_content = "line1\n new line\n line2" ;
317330 let fixture = ToolOperation :: FsPatch {
318331 input : forge_domain:: FSPatch {
319332 path : "/home/user/project/large_file.txt" . to_string ( ) ,
@@ -324,7 +337,8 @@ mod tests {
324337 output : PatchOutput {
325338 warning : Some ( "Large file modification" . to_string ( ) ) ,
326339 before : "line1\n line2" . to_string ( ) ,
327- after : "line1\n new line\n line2" . to_string ( ) ,
340+ after : after_content. to_string ( ) ,
341+ content_hash : crate :: compute_hash ( after_content) ,
328342 } ,
329343 } ;
330344 let env = fixture_environment ( ) ;
0 commit comments