fixed tests
This commit is contained in:
parent
ffc0659a84
commit
e4e33ebda2
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -17,6 +17,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@ -210,6 +216,7 @@ dependencies = [
|
||||
name = "github"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"clap",
|
||||
"comfy-table",
|
||||
"dirs",
|
||||
|
@ -16,6 +16,7 @@ serde = { version = "1.0.152", features = ["derive"] }
|
||||
serde_json = "1.0.91"
|
||||
comfy-table = "6.1.4"
|
||||
pretty_assertions = "1.3.0"
|
||||
base64 = "0.21.0"
|
||||
|
||||
[dev-dependencies]
|
||||
mockall = "0.11.2"
|
||||
|
@ -75,6 +75,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
use base64::Engine;
|
||||
use pretty_assertions::{assert_eq, assert_ne};
|
||||
|
||||
#[test]
|
||||
@ -129,16 +130,30 @@ mod tests {
|
||||
},
|
||||
},
|
||||
];
|
||||
let expected_table = "─────────────────────────────────────────────
|
||||
repo title number
|
||||
═════════════════════════════════════════════
|
||||
some-name some-title 0
|
||||
─────────────────────────────────────────────
|
||||
some-other-name some-other-title 1
|
||||
─────────────────────────────────────────────";
|
||||
|
||||
let expected_table = "4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSAChtbMW0gcmVwbyAgICAgICAgICAgIBtbMG0gG1sxbSB0aXRsZSAgICAgICAgICAgIBtbMG0gG1sxbSBudW1iZXIgG1swbQrilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZDilZAKG1szODs1OzEwbSBzb21lLW5hbWUgICAgICAgG1szOW0gIHNvbWUtdGl0bGUgICAgICAgICAwICAgICAgCuKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgOKUgAobWzM4OzU7MTBtIHNvbWUtb3RoZXItbmFtZSAbWzM5bSAgc29tZS1vdGhlci10aXRsZSAgIDEgICAgICAK4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA";
|
||||
let output = Review::generate_prs_table(&prs);
|
||||
|
||||
assert_eq!(output, expected_table.to_string())
|
||||
compare_tables(output, expected_table)
|
||||
}
|
||||
|
||||
fn compare_tables(actual: String, snapshot: &str) {
|
||||
let b64 = base64::engine::general_purpose::STANDARD_NO_PAD;
|
||||
let snapshot = snapshot.clone().replace("\n", "").replace(" ", "");
|
||||
println!("expected");
|
||||
println!(
|
||||
"{}",
|
||||
std::str::from_utf8(
|
||||
b64.decode(&snapshot)
|
||||
.expect("table to be decodeable")
|
||||
.as_slice()
|
||||
)
|
||||
.expect("to be utf8")
|
||||
);
|
||||
|
||||
println!("actual");
|
||||
println!("{actual}");
|
||||
|
||||
assert_eq!(b64.encode(actual), snapshot);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user