From abd539ddb8778a19f32d8ed7e030a28670e1c580 Mon Sep 17 00:00:00 2001 From: Jürgen Hahn Date: Wed, 4 Jan 2023 12:26:37 +0100 Subject: feat(tvix/derivation) Add fmt::Display implementation for Derivation This adds the implementation of fmt::Display for Derivation so that we can easily store the formatted content as a string. Internally, we use the serialization function to generate the string. Change-Id: I6caca0d6c1bea3ca44b6c535c5b1d5d66d8413b7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7741 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/derivation/src/tests/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tvix/derivation/src/tests/mod.rs') diff --git a/tvix/derivation/src/tests/mod.rs b/tvix/derivation/src/tests/mod.rs index 800806926976..3d4aae3fe4d4 100644 --- a/tvix/derivation/src/tests/mod.rs +++ b/tvix/derivation/src/tests/mod.rs @@ -14,7 +14,8 @@ fn read_file(path: &str) -> String { return data; } -fn assert_derivation_ok(path_to_drv_file: &str) { +#[test_resources("src/tests/derivation_tests/*.drv")] +fn check_serizaliation(path_to_drv_file: &str) { let data = read_file(&format!("{}.json", path_to_drv_file)); let derivation: Derivation = serde_json::from_str(&data).expect("JSON was not well-formatted"); @@ -27,6 +28,11 @@ fn assert_derivation_ok(path_to_drv_file: &str) { } #[test_resources("src/tests/derivation_tests/*.drv")] -fn derivation_files_ok(path: &str) { - assert_derivation_ok(path); +fn check_to_string(path_to_drv_file: &str) { + let data = read_file(&format!("{}.json", path_to_drv_file)); + let derivation: Derivation = serde_json::from_str(&data).expect("JSON was not well-formatted"); + + let expected = read_file(path_to_drv_file); + + assert_eq!(expected, derivation.to_string()); } -- cgit 1.4.1