@@ -186,7 +186,7 @@ fn extract_artifact_id_and_content(
186
186
key : & String ,
187
187
value : & serde_json:: Value ,
188
188
) -> Result < ( ArtifactId , FileContent ) , String > {
189
- let json_content = serde_json:: to_string ( value) . map_err ( |e| e. to_string ( ) ) ?;
189
+ let json_content = serde_json:: to_string_pretty ( value) . map_err ( |e| e. to_string ( ) ) ?;
190
190
Ok ( ( key. to_owned ( ) , json_content) )
191
191
}
192
192
@@ -327,22 +327,36 @@ fn b() {}
327
327
}
328
328
329
329
#[ test]
330
- fn read_artifacts_json_file ( ) {
330
+ fn parse_artifacts_json_into_btree_of_key_and_pretty_sub_json ( ) {
331
331
let dir = get_temp_dir ( "read_artifacts_json_file" ) ;
332
332
let file = dir. join ( "test.json" ) ;
333
- let json_content = r#"{
333
+ fs:: write (
334
+ & file,
335
+ r#"{
334
336
"hash1": { "name": "artifact1" },
335
337
"hash2": { "name": "artifact2" }
336
- }"# ;
337
- let expected = BTreeMap :: from ( [
338
- ( "hash1" . to_string ( ) , r#"{"name":"artifact1"}"# . to_string ( ) ) ,
339
- ( "hash2" . to_string ( ) , r#"{"name":"artifact2"}"# . to_string ( ) ) ,
340
- ] ) ;
341
-
342
- fs:: write ( & file, json_content) . unwrap ( ) ;
338
+ }"# ,
339
+ )
340
+ . unwrap ( ) ;
343
341
344
342
let id_per_json = FakeAggregatorData :: read_artifacts_json_file ( & file) ;
345
343
344
+ let expected = BTreeMap :: from ( [
345
+ (
346
+ "hash1" . to_string ( ) ,
347
+ r#"{
348
+ "name": "artifact1"
349
+ }"#
350
+ . to_string ( ) ,
351
+ ) ,
352
+ (
353
+ "hash2" . to_string ( ) ,
354
+ r#"{
355
+ "name": "artifact2"
356
+ }"#
357
+ . to_string ( ) ,
358
+ ) ,
359
+ ] ) ;
346
360
assert_eq ! ( expected, id_per_json) ;
347
361
}
348
362
}
0 commit comments