summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-02 18:59:11 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-02 18:59:32 +0100
commit13cbffb80029592d822c73a74bb22d29896c2423 (patch)
treeb9b55ea0a4f669e0f0871d76c00a62a71000a07b /src
parent9bfda194d73aa01ca34925f0dd40df281fd9d993 (diff)
Add test for profile creation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/profile.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/profile.rs b/src/profile.rs
index b78dfc1..21ab4e0 100644
--- a/src/profile.rs
+++ b/src/profile.rs
@@ -97,3 +97,43 @@ impl Profile {
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::client::Client;
+ use crate::config::Config;
+ use crate::ipfs_client::IpfsClient;
+
+ use ipfs_api_backend_hyper::TryFromUri;
+
+ async fn mk_client() -> Client {
+ let ipfs = IpfsClient::from_str("http://localhost:5001").unwrap();
+ let config = Config::default();
+ Client::new(ipfs, config)
+ }
+
+ macro_rules! run_test {
+ ($name:ident, $client:ident, $test:block) => {
+ $client.ipfs.key_rm($name).await;
+ {
+ $test
+ }
+ $client.ipfs.key_rm($name).await;
+ }
+ }
+
+ #[tokio::test]
+ async fn test_create_profile() {
+ let _ = env_logger::try_init();
+ let client = mk_client().await;
+ let name = "test_create_profile";
+ run_test!(name, client,
+ {
+ let p = Profile::create(name, &client).await;
+ assert!(p.is_ok());
+ }
+ );
+ }
+
+}