From 68b466502b86643dd16c2b4afb75205a91b3805a Mon Sep 17 00:00:00 2001 From: appflowy Date: Tue, 6 Jul 2021 19:29:39 +0800 Subject: [PATCH] add hook --- .githook/pre-commit | 4 ++++ .githook/pre-push | 21 +++++++++++++++++++++ rust-lib/flowy-user/tests/sign_in.rs | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100755 .githook/pre-commit create mode 100755 .githook/pre-push diff --git a/.githook/pre-commit b/.githook/pre-commit new file mode 100755 index 0000000000..eb09ba97ff --- /dev/null +++ b/.githook/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +#flutter format . + diff --git a/.githook/pre-push b/.githook/pre-push new file mode 100755 index 0000000000..72c666bcb0 --- /dev/null +++ b/.githook/pre-push @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +cd flutter-lib +if [[ `git status --porcelain` ]]; then + printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.' + exit 1 +fi +printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer' +flutter analyze +if [ $? -ne 0 ]; then + printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error' + exit 1 +fi +printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer' +printf "\e[33;1m%s\e[0m\n" 'Running unit tests' + +#flutter test +#if [ $? -ne 0 ]; then +# printf "\e[31;1m%s\e[0m\n" 'Unit tests error' +# exit 1 +#fi +#printf "\e[33;1m%s\e[0m\n" 'Finished running unit tests' diff --git a/rust-lib/flowy-user/tests/sign_in.rs b/rust-lib/flowy-user/tests/sign_in.rs index c625114b44..4d886d7565 100644 --- a/rust-lib/flowy-user/tests/sign_in.rs +++ b/rust-lib/flowy-user/tests/sign_in.rs @@ -16,6 +16,21 @@ fn sign_in_without_password() { dbg!(&result); } +#[test] +#[should_panic] +fn sign_in_with_invalid_password() { + let params = UserSignInParams { + email: "annie@appflowy.io".to_string(), + password: "123".to_string(), + }; + + let result = EventTester::new(SignIn) + .payload(params) + .assert_status_code(StatusCode::Err) + .sync_send::(); + dbg!(&result); +} + #[test] #[should_panic] fn sign_in_without_email() {