Skip to content

Commit

Permalink
chore: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
appflowy committed Jan 23, 2024
1 parent 1cf3a05 commit 8d446fb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libs/client-api-test-util/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::log::setup_log;
use client_api::Client;
use dotenv::dotenv;
use lazy_static::lazy_static;
use tracing_subscriber::fmt::format;
use uuid::Uuid;

lazy_static! {
Expand All @@ -27,6 +28,12 @@ pub fn generate_unique_email() -> String {

pub async fn admin_user_client() -> Client {
let admin_client = localhost_client();
#[cfg(target_arch = "wasm32")]
{
let msg = format!("{}", admin_client);
web_sys::console::log_1(&msg.into());
}

admin_client
.sign_in_password(&ADMIN_USER.email, &ADMIN_USER.password)
.await
Expand Down
10 changes: 10 additions & 0 deletions libs/client-api/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::notify::{ClientToken, TokenStateReceiver};
use anyhow::Context;
use brotli::CompressorReader;
use gotrue_entity::dto::AuthProvider;
use std::fmt::{Display, Formatter, Write};
use std::io::Read;

use app_error::AppError;
Expand Down Expand Up @@ -1169,6 +1170,15 @@ impl Client {
}
}

impl Display for Client {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"Client {{ base_url: {}, ws_addr: {}, gotrue_url: {} }}",
self.base_url, self.ws_addr, self.gotrue_client.base_url
))
}
}

fn url_missing_param(param: &str) -> AppResponseError {
AppError::InvalidRequest(format!("Url Missing Parameter:{}", param)).into()
}
Expand Down
2 changes: 1 addition & 1 deletion libs/wasm-test/tests/conn_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use client_api_test_util::generate_unique_registered_user_client;
use wasm_bindgen_test::wasm_bindgen_test;

#[wasm_bindgen_test]
async fn realtime_connect_test() {
async fn wasm_websocket_connect_test() {
let (c, _user) = generate_unique_registered_user_client().await;
let ws_client = WSClient::new(WSClientConfig::default(), c.clone());
let mut state = ws_client.subscribe_connect_state();
Expand Down
2 changes: 1 addition & 1 deletion libs/wasm-test/tests/user_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use client_api_test_util::{generate_unique_email, localhost_client};
use wasm_bindgen_test::wasm_bindgen_test;

#[wasm_bindgen_test]
async fn sign_up_success() {
async fn wasm_sign_up_success() {
let email = generate_unique_email();
let password = "Hello!123#";
let c = localhost_client();
Expand Down

0 comments on commit 8d446fb

Please sign in to comment.