Skip to content

Commit

Permalink
Update and fixed fake and quickcheck
Browse files Browse the repository at this point in the history
- Reference: LukeMathWalker/zero-to-production#34
- Update `fake` to 2.6 and `quickcheck` to 1
- `fake` 2.6 depending on `rand` 0.8
  • Loading branch information
trinhlehainamvice committed Jul 27, 2023
1 parent cae8600 commit a97e760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ features = [
[dev-dependencies]
once_cell = "1"
claim = "0.5"
# Fake >= 2.4 version relies on rand 0.8
# which quickcheck haven't supported yet
fake = "2.3"
quickcheck = "0.9"
quickcheck_macros = "0.9"
fake = "2.6"
rand = "0.8"
quickcheck = "1"
quickcheck_macros = "1"
wiremock = "0.5"
tokio = { version = "1", features = ["rt"] }
serde_json = "1"
8 changes: 5 additions & 3 deletions src/routes/domain/subscriber_email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ mod tests {
use crate::routes::SubscriberEmail;
use fake::faker::internet::en::SafeEmail;
use fake::Fake;
use quickcheck::Gen;
use rand::prelude::StdRng;
use rand::SeedableRng;

#[derive(Debug, Clone)]
struct ValidEmailFixture(pub String);

impl quickcheck::Arbitrary for ValidEmailFixture {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
let email = SafeEmail().fake_with_rng(g);
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
let mut rng = StdRng::seed_from_u64(u64::arbitrary(g));
let email = SafeEmail().fake_with_rng(&mut rng);
Self(email)
}
}
Expand Down

0 comments on commit a97e760

Please sign in to comment.