Skip to content

Commit

Permalink
fix: shared lib unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Apr 29, 2022
1 parent fa3a28e commit f102ca3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 5 additions & 3 deletions shared-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion shared-lib/flowy-user-data-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
[dev-dependencies]
quickcheck = "1.0.3"
quickcheck_macros = "0.9.1"
fake = "~2.3.0"
fake = "2.4.3"
claim = "0.4.0"
futures = "0.3.15"
serial_test = "0.5.1"
rand_core = "0.6.3"
rand = "0.8.5"

[features]
dart = ["lib-infra/dart", "flowy-error-code/dart"]
11 changes: 9 additions & 2 deletions shared-lib/flowy-user-data-model/src/parser/user_email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ mod tests {
use super::*;
use claim::assert_err;
use fake::{faker::internet::en::SafeEmail, Fake};
use rand::prelude::StdRng;
use rand_core::SeedableRng;

#[test]
fn empty_string_is_rejected() {
Expand All @@ -52,8 +54,13 @@ mod tests {
struct ValidEmailFixture(pub String);

impl quickcheck::Arbitrary for ValidEmailFixture {
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
let email = SafeEmail().fake_with_rng(g);
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
let mut rand_slice: [u8; 32] = [0; 32];
for i in 0..32 {
rand_slice[i] = u8::arbitrary(g);
}
let mut seed = StdRng::from_seed(rand_slice);
let email = SafeEmail().fake_with_rng(&mut seed);
Self(email)
}
}
Expand Down

0 comments on commit f102ca3

Please sign in to comment.