Skip to content

Commit

Permalink
Created new tests for checking custom named golden files
Browse files Browse the repository at this point in the history
  • Loading branch information
Trent Graw committed Nov 30, 2024
1 parent ff698ed commit 431b60a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ fn goldie_assert() {
crate::assert!("testing...\n");
}

#[test]
fn goldie_assert_custom_path() {
crate::assert!("goldie_assert-custom", "custom testing...\n");
}

#[test]
fn goldie_assert_debug() {
#[allow(dead_code)]
Expand All @@ -54,6 +59,22 @@ fn goldie_assert_debug() {

crate::assert_debug!(&u);
}
#[test]
fn goldie_assert_debug_custom_path() {
#[allow(dead_code)]
#[derive(Debug)]
struct User {
name: &'static str,
surname: &'static str,
}

let u = User {
name: "custom Steve",
surname: "custom Harrington",
};

crate::assert_debug!("goldie_assert_debug-custom", &u);
}

#[test]
fn goldie_assert_template() {
Expand All @@ -65,6 +86,16 @@ fn goldie_assert_template() {
crate::assert_template!(&ctx, "Such testing...\n");
}

#[test]
fn goldie_assert_template_custom_path() {
#[derive(Serialize)]
struct Context {
test: &'static str,
}
let ctx = Context { test: "custom testing..." };
crate::assert_template!("goldie_assert_template-custom", &ctx, "Such custom testing...\n");
}

#[test]
fn goldie_assert_json() {
#[derive(Serialize)]
Expand All @@ -80,3 +111,19 @@ fn goldie_assert_json() {

crate::assert_json!(&u);
}

#[test]
fn goldie_assert_json_custom_path() {
#[derive(Serialize)]
struct User {
name: &'static str,
surname: &'static str,
}

let u = User {
name: "custom Steve",
surname: "custom Harrington",
};

crate::assert_json!("goldie_assert_json-custom", &u);
}

0 comments on commit 431b60a

Please sign in to comment.