-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
470 additions
and
189 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "client-api-test-util" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
bytes = "1.5.0" | ||
mime = "0.3.17" | ||
serde_json = "1.0.111" | ||
tokio = { version = "1.0", features = ["sync"] } | ||
tokio-stream = "0.1.14" | ||
tracing.workspace = true | ||
collab-folder.workspace = true | ||
collab = { workspace = true, features = ["async-plugin"] } | ||
client-api = { path = "../client-api", features = ["collab-sync", "test_util"] } | ||
once_cell = "1.19.0" | ||
tempfile = "3.9.0" | ||
assert-json-diff = "2.0.2" | ||
scraper = "0.17.1" | ||
opener = "0.6.1" | ||
image = "0.23.14" | ||
database-entity.workspace = true | ||
collab-entity.workspace = true | ||
shared-entity.workspace = true | ||
tracing-subscriber = { version = "0.3.18", features = ["registry", "env-filter", "ansi", "json"] } | ||
uuid = "1.6.1" | ||
lazy_static = "1.4.0" | ||
dotenv = "0.15.0" | ||
reqwest = "0.11.23" | ||
gotrue.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use client_api::{Client, ClientConfiguration}; | ||
use dotenv::dotenv; | ||
use lazy_static::lazy_static; | ||
use std::borrow::Cow; | ||
use std::env; | ||
use tracing::warn; | ||
|
||
lazy_static! { | ||
pub static ref LOCALHOST_URL: Cow<'static, str> = | ||
get_env_var("LOCALHOST_URL", "http://localhost:8000"); | ||
pub static ref LOCALHOST_WS: Cow<'static, str> = | ||
get_env_var("LOCALHOST_WS", "ws://localhost:8000/ws"); | ||
pub static ref LOCALHOST_GOTRUE: Cow<'static, str> = | ||
get_env_var("LOCALHOST_GOTRUE", "http://localhost:9999"); | ||
} | ||
|
||
fn get_env_var<'default>(key: &str, default: &'default str) -> Cow<'default, str> { | ||
dotenv().ok(); | ||
match env::var(key) { | ||
Ok(value) => Cow::Owned(value), | ||
Err(_) => { | ||
warn!("could not read env var {}: using default: {}", key, default); | ||
Cow::Borrowed(default) | ||
}, | ||
} | ||
} | ||
|
||
/// Return a client that connects to the local host. It requires to run the server locally. | ||
/// ```shell | ||
/// ./build/run_local_server.sh | ||
/// ``` | ||
pub fn localhost_client() -> Client { | ||
Client::new( | ||
&LOCALHOST_URL, | ||
&LOCALHOST_WS, | ||
&LOCALHOST_GOTRUE, | ||
ClientConfiguration::default(), | ||
) | ||
} | ||
|
||
pub async fn workspace_id_from_client(c: &Client) -> String { | ||
c.get_workspaces() | ||
.await | ||
.unwrap() | ||
.0 | ||
.first() | ||
.unwrap() | ||
.workspace_id | ||
.to_string() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod client; | ||
mod log; | ||
mod test_client; | ||
mod user; | ||
|
||
pub use client::*; | ||
pub use log::*; | ||
pub use test_client::*; | ||
pub use user::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.