Skip to content

Commit

Permalink
chore(example/load_resource): Move away from dbg to using assert_eq
Browse files Browse the repository at this point in the history
  • Loading branch information
448-OG committed Nov 11, 2023
1 parent eb3e1ef commit a3e65e2
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions Lib/examples/load_resource.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use file_format::FileFormat;
use puppeteer::{path_from_manifest, AssetFileLoader, AssetProperties, StaticAssetProperties};

fn main() {
Expand All @@ -8,28 +9,28 @@ fn main() {
.await
.unwrap();

dbg!(&resource.format());
dbg!(&resource.format().kind());
dbg!(&resource.format().media_type());
dbg!(&resource.format().short_name());
dbg!(&resource.name());
assert_eq!(FileFormat::WebOpenFontFormat2, resource.format());
assert_eq!(file_format::Kind::Font, resource.format().kind());
assert_eq!("font/woff2", resource.format().media_type());
assert_eq!(Some("WOFF2"), resource.format().short_name());
assert_eq!("centauri.woff2", &resource.name());

let resource = AssetFileLoader::new("frow.min.css")
.add_dir("examples/assets")
.load()
.await
.unwrap();

dbg!(&resource.format());
dbg!(&resource.format().kind());
dbg!(&resource.format().media_type());
dbg!(&resource.format().short_name());
dbg!(&resource.name());
assert_eq!(FileFormat::PlainText, resource.format());
assert_eq!(file_format::Kind::Text, resource.format().kind());
assert_eq!("text/plain", resource.format().media_type());
assert_eq!(Some("TXT"), resource.format().short_name());
assert_eq!("frow.min.css", resource.name());

let frowcss = puppeteer::asset!("frow.min", "examples/assets/frow.min.css");

dbg!(frowcss.name());
dbg!(frowcss.format().media_type());
assert_eq!("frow.min", frowcss.name());
assert_eq!("text/plain", frowcss.format().media_type());

let _path = path_from_manifest!("examples/assets", "frow.min.css");

Expand All @@ -38,7 +39,10 @@ fn main() {
let counter = puppeteer::items_counter!(1, 2, 3);
assert_eq!(counter, 3usize);

dbg!(puppeteer::concat_paths!("foo", "bar", "baz", "foo.txt"));
assert_eq!(
"foo/bar/baz/foo.txt",
&puppeteer::concat_paths!("foo", "bar", "baz", "foo.txt")
);

let assets = puppeteer::load_assets!(
("frow.min", "assets/frow.min.css"),
Expand All @@ -49,7 +53,18 @@ fn main() {
"0b3ae879a79a09c1aa75f82b8f4a2482f08842b511b4b075484996e29cd7c3b0",
blake3::hash(assets[0].bytes).to_hex().as_str()
);
assert_eq!(
"b67a70f6e41e9dc758a1ab6b24d30865df90446fb155d6fb905c5789b3f43ce3",
blake3::hash(assets[1].bytes).to_hex().as_str()
);
assert_eq!(
"53a3c3ce4bdb8062c464f624a72a8c7589cc04c612ffbfbf3b07e36e45249104",
blake3::hash(assets[2].bytes).to_hex().as_str()
);

dbg!(puppeteer::manifest_paths!("foo", "bar", "baz", "foo.txt"));
assert_eq!(
format!("{}/foo/bar/baz/foo.txt", env!("CARGO_MANIFEST_DIR")).as_str(),
&puppeteer::manifest_paths!("foo", "bar", "baz", "foo.txt")
);
})
}

0 comments on commit a3e65e2

Please sign in to comment.