Skip to content

Commit 163ad3b

Browse files
committed
[api] add client test module, remove test crate
1 parent abdfda2 commit 163ad3b

8 files changed

Lines changed: 53 additions & 54 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.3.0"
44

55
members = [
66
"rain_client",
7-
"rain_client_test",
87
"rain_core",
98
"rain_server",
109
"rain_task",

rain_client/src/client/client.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,47 @@ impl Client {
2727
}
2828
}
2929

30+
#[cfg(test)]
31+
mod tests {
32+
use super::super::localcluster::LocalCluster;
33+
use super::super::tasks::CommonTasks;
34+
use super::Client;
35+
use super::Session;
36+
use std::env;
37+
38+
#[allow(dead_code)]
39+
struct TestContext {
40+
cluster: LocalCluster,
41+
client: Client,
42+
session: Session,
43+
}
44+
45+
fn ctx() -> TestContext {
46+
let rain = env::var("RAIN_BINARY").unwrap();
47+
48+
let cluster = LocalCluster::new(&rain).unwrap();
49+
let client = cluster.create_client().unwrap();
50+
let session = client.new_session().unwrap();
51+
52+
TestContext {
53+
cluster,
54+
client,
55+
session,
56+
}
57+
}
58+
59+
#[test]
60+
fn concat() {
61+
let mut ctx = ctx();
62+
let a = ctx.session.blob(vec![1, 2, 3]);
63+
let b = ctx.session.blob(vec![4, 5, 6]);
64+
let c = ctx.session.concat(&[a, b]);
65+
c.output().keep();
66+
ctx.session.submit().unwrap();
67+
ctx.session.wait(&[c.clone()], &[]).unwrap();
68+
assert_eq!(
69+
ctx.session.fetch(&c.output()).unwrap(),
70+
vec![1, 2, 3, 4, 5, 6]
71+
);
72+
}
73+
}

rain_client/src/client/localcluster.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1+
use super::client::Client;
12
use std::error::Error;
23
use std::net::SocketAddr;
3-
use super::client::Client;
4-
use std::process::{Child, Command};
54
use std::path::PathBuf;
6-
use std::{thread, time};
7-
use std::process::Stdio;
5+
use std::process::{Command, Stdio};
86

97
pub struct LocalCluster {
108
listen_addr: SocketAddr,
11-
binary: PathBuf
9+
binary: PathBuf,
1210
}
1311

1412
impl LocalCluster {
1513
pub fn new(binary: &str) -> Result<Self, Box<Error>> {
1614
let mut cluster = LocalCluster {
1715
binary: PathBuf::from(binary),
18-
listen_addr: SocketAddr::new("127.0.0.1".parse()?, 7210)
16+
listen_addr: SocketAddr::new("127.0.0.1".parse()?, 7210),
1917
};
2018
cluster.start()?;
2119

@@ -43,6 +41,7 @@ impl LocalCluster {
4341
}
4442

4543
impl Drop for LocalCluster {
44+
#![allow(unused_must_use)]
4645
fn drop(&mut self) {
4746
Client::new(self.listen_addr).unwrap().terminate_server();
4847
}

rain_client/src/client/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub mod client;
2+
pub mod localcluster;
23
pub mod session;
34
pub mod tasks;
4-
pub mod localcluster;
55

66
#[macro_use]
77
mod rpc;
@@ -10,5 +10,5 @@ mod dataobject;
1010
mod task;
1111

1212
pub use self::client::Client;
13-
pub use self::session::Session;
1413
pub use self::localcluster::LocalCluster;
14+
pub use self::session::Session;

rain_client/src/client/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ impl Session {
160160
}
161161

162162
impl Drop for Session {
163+
#![allow(unused_must_use)]
163164
fn drop(&mut self) {
164-
self.comm.close_session(self.id).unwrap();
165165
debug!("Session {} destroyed", self.id);
166+
self.comm.close_session(self.id);
166167
}
167168
}

rain_client_test/Cargo.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

rain_client_test/src/main.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)