Skip to content

Commit 38db0a2

Browse files
committed
TestApp: Adjust emails_snapshot() to replace ISO8601 dates
Most `created_at` rows in the database default to `now()`, which can cause `insta` snapshots to be unstable when the content changes between runs due to the nature of time itself. This change adjusts the `emails_snapshot()` fn to replace the ISO8601 dates with a placeholder, which should cause the snapshots to become stable.
1 parent ee48d63 commit 38db0a2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/tests/util/test_app.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ impl TestApp {
177177
static EMAIL_HEADER_REGEX: LazyLock<Regex> =
178178
LazyLock::new(|| Regex::new(r"(Message-ID|Date): [^\r\n]+\r\n").unwrap());
179179

180+
static DATE_TIME_REGEX: LazyLock<Regex> =
181+
LazyLock::new(|| Regex::new(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z").unwrap());
182+
180183
static INVITE_TOKEN_REGEX: LazyLock<Regex> =
181184
LazyLock::new(|| Regex::new(r"/accept-invite/\w+").unwrap());
182185

@@ -186,6 +189,7 @@ impl TestApp {
186189
.into_iter()
187190
.map(|email| {
188191
let email = EMAIL_HEADER_REGEX.replace_all(&email, "");
192+
let email = DATE_TIME_REGEX.replace_all(&email, "[0000-00-00T00:00:00Z]");
189193
let email = INVITE_TOKEN_REGEX.replace_all(&email, "/accept-invite/[invite-token]");
190194
email.to_string()
191195
})

0 commit comments

Comments
 (0)