summaryrefslogtreecommitdiff
path: root/rust/tests/collaboration.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-16 16:13:35 -0400
committerMason Reed <mason@vector35.com>2025-07-17 06:20:20 -0400
commitec2d4e2f5c8efbc0985f27f2dc924eb388cfb243 (patch)
tree06d46de6106385406522380e3bbd1f064490e8ec /rust/tests/collaboration.rs
parent38ff3609c4e2b655c069c0f5c2a7fe1f24d67824 (diff)
[Rust] Misc fixes / formatting
- Fix cmake clean not cleaning target docs - Fix not prioritizing enterprise remote in collab tests - Some misc formatting - Fix incorrect assert in binary loading
Diffstat (limited to 'rust/tests/collaboration.rs')
-rw-r--r--rust/tests/collaboration.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/rust/tests/collaboration.rs b/rust/tests/collaboration.rs
index 85f8702e..529e185b 100644
--- a/rust/tests/collaboration.rs
+++ b/rust/tests/collaboration.rs
@@ -18,7 +18,7 @@ fn temp_project_scope<T: Fn(&RemoteProject)>(remote: &Remote, project_name: &str
// TODO: Because connecting is not thread safe we wont check the error here, this is because we might already
// TODO: be connecting in some other thread and will error out on this thread. But we _probably_ will
// TODO: have connected by the time this errors out. Maybe?
- let _ = remote.connect();
+ remote.connect().expect("Failed to connect to remote");
}
let project = remote
.create_project(project_name, "Test project for test purposes")
@@ -50,13 +50,18 @@ fn temp_project_scope<T: Fn(&RemoteProject)>(remote: &Remote, project_name: &str
/// Get the selected remote to test with.
fn selected_remote() -> Option<Ref<Remote>> {
- // If the user has initialized with a enterprise server we might already have an active remote.
+ // TODO: Ability to override this with some environment variable?
+ // Assuming we already have called this we will have an active remote.
match binaryninja::collaboration::active_remote() {
Some(remote) => Some(remote),
- None => {
- let remotes = binaryninja::collaboration::known_remotes();
- remotes.iter().next().map(|r| r.clone())
- }
+ // Assuming the user is initialized with an enterprise client we should contact that one first.
+ None => match binaryninja::collaboration::enterprise_remote() {
+ Some(remote) => Some(remote),
+ None => {
+ let remotes = binaryninja::collaboration::known_remotes();
+ remotes.iter().next().map(|r| r.clone())
+ }
+ },
}
}
@@ -68,6 +73,13 @@ fn test_connection() {
eprintln!("No known remotes, skipping test...");
return;
};
+ // Another test might have already connected.
+ if remote.is_connected() {
+ remote
+ .disconnect()
+ .expect("Failed to disconnect from remote");
+ assert!(!remote.is_connected(), "Connection was not disconnected");
+ }
assert!(remote.connect().is_ok(), "Failed to connect to remote");
remote
.disconnect()