Skip to content

Commit

Permalink
split unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haerdib committed Feb 19, 2024
1 parent 4f312aa commit 9c580cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/rpc/tungstenite_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,15 @@ mod tests {
let address = "ws://127.0.0.1";
let client = TungsteniteRpcClient::new_with_port(address, port, 1).unwrap();

let client2 = TungsteniteRpcClient::with_default_url(1);
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
assert_eq!(client.url, expected_url);
}

#[test]
fn client_with_default_url() {
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
let client = TungsteniteRpcClient::with_default_url(1);

assert_eq!(client.url, client2.url);
assert_eq!(client.url, expected_url);
}
}
13 changes: 10 additions & 3 deletions src/rpc/ws_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl WsRpcClient {
/// Create a new client with the given url string.
/// Example url input: "ws://127.0.0.1:9944"
pub fn new(url: &str) -> Result<Self> {
let url: Url = Url::parse(url)?;
let url = Url::parse(url)?;
Ok(Self { url })
}

Expand Down Expand Up @@ -152,8 +152,15 @@ mod tests {
let address = "ws://127.0.0.1";
let client = WsRpcClient::new_with_port(address, port).unwrap();

let client2 = WsRpcClient::with_default_url();
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
assert_eq!(client.url, expected_url);
}

#[test]
fn client_with_default_url() {
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
let client = WsRpcClient::with_default_url();

assert_eq!(client.url, client2.url);
assert_eq!(client.url, expected_url);
}
}

0 comments on commit 9c580cc

Please sign in to comment.