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 <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
00dab6142e
commit
abd539ddb8
3 changed files with 42 additions and 22 deletions
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue