Skip to content

Commit afc48ee

Browse files
committed
tests: Add more email assertions
1 parent 38db0a2 commit afc48ee

File tree

8 files changed

+37
-0
lines changed

8 files changed

+37
-0
lines changed

src/tests/krate/publish/auth.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async fn new_wrong_token() {
2929
assert_eq!(response.status(), StatusCode::FORBIDDEN);
3030
assert_snapshot!(response.text(), @r###"{"errors":[{"detail":"authentication failed"}]}"###);
3131
assert_that!(app.stored_files().await, empty());
32+
assert_that!(app.emails(), empty());
3233
}
3334

3435
#[tokio::test(flavor = "multi_thread")]
@@ -49,4 +50,5 @@ async fn new_krate_wrong_user() {
4950
assert_json_snapshot!(response.json());
5051

5152
assert_that!(app.stored_files().await, empty());
53+
assert_that!(app.emails(), empty());
5254
}

src/tests/krate/publish/basics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ async fn new_krate() {
3636
.unwrap();
3737
assert_eq!(email, "foo@example.com");
3838
});
39+
40+
assert_snapshot!(app.emails_snapshot());
3941
}
4042

4143
#[tokio::test(flavor = "multi_thread")]

src/tests/krate/publish/emails.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async fn new_krate_without_any_email_fails() {
2020
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
2121
assert_json_snapshot!(response.json());
2222
assert_that!(app.stored_files().await, empty());
23+
assert_that!(app.emails(), empty());
2324
}
2425

2526
#[tokio::test(flavor = "multi_thread")]
@@ -39,4 +40,5 @@ async fn new_krate_with_unverified_email_fails() {
3940
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
4041
assert_json_snapshot!(response.json());
4142
assert_that!(app.stored_files().await, empty());
43+
assert_that!(app.emails(), empty());
4244
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/tests/krate/publish/basics.rs
3+
expression: app.emails_snapshot()
4+
---
5+

src/tests/owners.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ async fn new_crate_owner() {
156156
.publish_crate(crate_to_publish)
157157
.await
158158
.good();
159+
160+
assert_snapshot!(app.emails_snapshot());
159161
}
160162

161163
async fn create_and_add_owner(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: src/tests/owners.rs
3+
expression: app.emails_snapshot()
4+
---
5+
To: Bar@example.com
6+
From: noreply@crates.io
7+
Subject: crates.io: Ownership invitation for "foo_owner"
8+
Content-Type: text/plain; charset=utf-8
9+
Content-Transfer-Encoding: quoted-printable
10+
11+
foo has invited you to become an owner of the crate foo_owner!
12+
13+
Visit https://crates.io/accept-invite/[invite-token] to accept =
14+
this invitation,
15+
or go to https://crates.io/me/pending-invites to manage all of your crate o=
16+
wnership invitations.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: src/tests/team.rs
3+
expression: app.emails_snapshot()
4+
---
5+

src/tests/team.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crates_io::{
1010

1111
use diesel::*;
1212
use http::StatusCode;
13+
use insta::assert_snapshot;
1314

1415
impl crate::util::MockAnonymousUser {
1516
/// List the team owners of the specified crate.
@@ -399,6 +400,8 @@ async fn publish_owned() {
399400
.publish_crate(crate_to_publish)
400401
.await
401402
.good();
403+
404+
assert_snapshot!(app.emails_snapshot());
402405
}
403406

404407
/// Test trying to change owners (when only on an owning team)

0 commit comments

Comments
 (0)