Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: shared lib unit test

appflowyf102ca3c853a
diff --git a/shared-lib/Cargo.lock b/shared-lib/Cargo.lock
index 8071cee469..03cf7bc02d 100644
--- a/shared-lib/Cargo.lock
+++ b/shared-lib/Cargo.lock
@@ -351,11 +351,11 @@ dependencies = [
[[package]]
name = "fake"
-version = "2.3.0"
+version = "2.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6479fa2c7e83ddf8be7d435421e093b072ca891b99a49bc84eba098f4044f818"
+checksum = "21a8531dd3a64fd1cfbe92fad4160bc2060489c6195fe847e045e5788f710bae"
dependencies = [
- "rand 0.7.3",
+ "rand 0.8.5",
]
[[package]]
@@ -505,6 +505,8 @@ dependencies = [
"protobuf",
"quickcheck",
"quickcheck_macros",
+ "rand 0.8.5",
+ "rand_core 0.6.3",
"serde",
"serial_test",
"unicode-segmentation",
diff --git a/shared-lib/flowy-user-data-model/Cargo.toml b/shared-lib/flowy-user-data-model/Cargo.toml
index 0b472b0ae0..916a6c79f9 100644
--- a/shared-lib/flowy-user-data-model/Cargo.toml
+++ b/shared-lib/flowy-user-data-model/Cargo.toml
@@ -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"]
diff --git a/shared-lib/flowy-user-data-model/src/parser/user_email.rs b/shared-lib/flowy-user-data-model/src/parser/user_email.rs
index 0a3ac03006..9b254f2957 100644
--- a/shared-lib/flowy-user-data-model/src/parser/user_email.rs
+++ b/shared-lib/flowy-user-data-model/src/parser/user_email.rs
@@ -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() {
@@ -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)
}
}