summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-11-27 10:46:34 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-11-27 10:50:11 +0100
commit2e78de6b2c50625ff4f9032157d097744598de65 (patch)
treeefd5c4d0ab2a866fe65cbb007976eb10df3aba1d
parent88515ac848d105c8c84efb2faea31b530a0554ee (diff)
Move tests to source
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/client.rs17
-rw-r--r--src/ipfs_client.rs15
-rw-r--r--src/main.rs12
-rw-r--r--tests/connect_test.rs12
-rw-r--r--tests/post_text_blob.rs14
5 files changed, 38 insertions, 32 deletions
diff --git a/src/client.rs b/src/client.rs
index 39f3598..8a9a276 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -34,3 +34,20 @@ impl Client {
}
}
+#[cfg(test)]
+mod tests {
+ use crate::client::Client;
+ use crate::config::Config;
+ use crate::ipfs_client::IpfsClient;
+
+ #[test]
+ fn test_post_text_blob() {
+ let ipfs = IpfsClient::from_str("http://localhost:5001").unwrap();
+ let config = Config::default();
+ let client = Client::new(ifps, config);
+
+ let cid = Client.post_text_blob(String::from("text"));
+ assert!(cid.is_ok());
+ }
+
+}
diff --git a/src/ipfs_client.rs b/src/ipfs_client.rs
index 4fce4dd..a4b3710 100644
--- a/src/ipfs_client.rs
+++ b/src/ipfs_client.rs
@@ -1 +1,16 @@
pub type IpfsClient = ipfs_api_backend_hyper::IpfsClient;
+
+#[cfg(test)]
+mod tests {
+ use super::IpfsClient;
+
+ #[test]
+ fn test_connect_str() {
+ let _ = IpfsClient::from_str("http://localhost:5001").unwrap();
+ }
+
+ #[test]
+ fn test_connect_host_and_port() {
+ let _ = IpfsClient::from_host_and_port("localhost", 5001).unwrap();
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index bacfe08..8b82975 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,12 +13,12 @@ use futures::stream::StreamExt;
extern crate clap_v3 as clap;
-mod cli;
-mod client;
-mod config;
-mod consts;
-mod ipfs_client;
-mod types;
+pub mod cli;
+pub mod client;
+pub mod config;
+pub mod consts;
+pub mod ipfs_client;
+pub mod types;
#[tokio::main]
async fn main() -> Result<()> {
diff --git a/tests/connect_test.rs b/tests/connect_test.rs
deleted file mode 100644
index 0e66f07..0000000
--- a/tests/connect_test.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use distrox::ipfs_client::IpfsClient;
-
-#[test]
-fn test_connect_str() {
- let _ = IpfsApi::from_str("http://localhost:5001").unwrap();
-}
-
-#[test]
-fn test_connect_host_and_port() {
- let _ = IpfsApi::from_host_and_port("localhost", 5001).unwrap();
-}
-
diff --git a/tests/post_text_blob.rs b/tests/post_text_blob.rs
deleted file mode 100644
index 2f1fa74..0000000
--- a/tests/post_text_blob.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use distrox::client::Client;
-use distrox::config::Config;
-use distrox::ipfs_client::IpfsClient;
-
-#[test]
-fn test_post_text_blob() {
- let ipfs = IpfsClient::from_str("http://localhost:5001").unwrap();
- let config = Config::default();
- let client = Client::new(ifps, config);
-
- let cid = Client.post_text_blob(String::from("text"));
- assert!(cid.is_ok());
-}
-