blob: 8a9a27654fb295728b4b65ec50df720cbcaefa41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
use anyhow::Result;
use cid::Cid;
use crate::config::Config;
use crate::ipfs_client::IpfsClient;
pub struct Client {
ipfs: IpfsClient,
config: Config,
}
impl std::fmt::Debug for Client {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "Client {{ config: {:?} }}", self.config)
}
}
impl Client {
pub fn new(ipfs: IpfsClient, config: Config) -> Self {
Client {
ipfs,
config
}
}
fn post_text_blob_impl(&self, text: String) -> Result<Cid> {
unimplemented!()
}
}
#[cfg(test)]
impl Client {
pub fn post_text_blob(&self, text: String) -> Result<Cid> {
self.post_text_blob_impl(text)
}
}
#[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());
}
}
|