Skip to content

Commit

Permalink
[format] improve test output
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2bd committed Sep 16, 2021
1 parent 1688dba commit 743c14a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions fastpay_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ serde = { version = "1.0.115", features = ["derive"] }
tokio = { version = "0.2.22", features = ["full"] }
ed25519 = { version = "1.0.1"}
ed25519-dalek = { version = "1.0.1", features = ["batch", "serde"] }
serde-reflection = "0.3.2"
serde-name = "0.1.2"
serde_yaml = "0.8.17"
structopt = "0.3.21"

[[bin]]
[dev-dependencies]
similar-asserts = { version = "1.1.0" }
serde-reflection = "0.3.2"
serde_yaml = "0.8.17"

[[example]]
name = "generate-format"
path = "src/generate_format.rs"
test = false
Expand Down
7 changes: 3 additions & 4 deletions fastpay_core/src/generate_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

use fastpay_core::{error, messages, serialize};

use serde_reflection::{Registry, Result, Samples, Tracer, TracerConfig};
use std::{fs::File, io::Write};
use structopt::{clap::arg_enum, StructOpt};
Expand Down Expand Up @@ -55,9 +54,9 @@ fn main() {
writeln!(f, "{}", content).unwrap();
}
Action::Test => {
let f = File::open(FILE_PATH).unwrap();
let reference: serde_reflection::Registry = serde_yaml::from_reader(f).unwrap();
assert_eq!(registry, reference);
let reference = std::fs::read_to_string(FILE_PATH).unwrap();
let content = serde_yaml::to_string(&registry).unwrap() + "\n";
similar_asserts::assert_str_eq!(&reference, &content);
}
}
}
3 changes: 2 additions & 1 deletion fastpay_core/tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

#[test]
fn test_format() {
let status = std::process::Command::new("target/debug/generate-format")
let status = std::process::Command::new("cargo")
.current_dir("..")
.args(&["run", "--example", "generate-format", "--"])
.arg("test")
.status()
.expect("failed to execute process");
Expand Down

0 comments on commit 743c14a

Please sign in to comment.