MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / test_project_creation

Function test_project_creation

rust/tests/collaboration.rs:87–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85#[rstest]
86#[serial]
87fn test_project_creation() {
88 let _session = Session::new().expect("Failed to initialize session");
89 let Some(remote) = selected_remote() else {
90 eprintln!("No known remotes, skipping test...");
91 return;
92 };
93 temp_project_scope(&remote, "test_creation", |project| {
94 // Create the file than verify it by opening and checking contents.
95 let created_file = project
96 .create_file(
97 "test_file",
98 b"this is my file",
99 "test_file",
100 "",
101 None,
102 RemoteFileType::UnknownFileType,
103 )
104 .expect("Failed to create file in project");
105 let created_file_id = created_file.id();
106 assert_eq!(created_file.created_by(), remote.username());
107 project
108 .delete_file(&created_file)
109 .expect("Failed to delete file");
110 assert!(
111 !project
112 .get_file_by_id(created_file_id)
113 .is_ok_and(|f| f.is_some()),
114 "File was not deleted"
115 );
116
117 // Create a folder and verify it was created.
118 let created_folder = project
119 .create_folder("test_folder", "test_folder_desc", None)
120 .unwrap();
121 let created_folder_id = created_folder.id();
122 assert_eq!(created_folder.name().as_str(), "test_folder");
123 assert_eq!(created_folder.description().as_str(), "test_folder_desc");
124
125 // Create a file in said folder and verify it exists in it.
126 let created_folder_file = project
127 .create_file(
128 "test_folder_file",
129 b"this is my file",
130 "test_folder_file",
131 "",
132 Some(&created_folder),
133 RemoteFileType::UnknownFileType,
134 )
135 .expect("Failed to create file in project folder");
136 let created_folder_file_id = created_folder_file.id();
137 // Verify the file exists in the folder.
138 let check_folder_file = project
139 .get_file_by_id(created_folder_file_id)
140 .expect("Failed to get folder file by id")
141 .unwrap();
142 assert_eq!(check_folder_file.name().as_str(), "test_folder_file");
143 assert_eq!(
144 check_folder_file.folder().unwrap().unwrap().id(),

Callers

nothing calls this directly

Calls 8

selected_remoteFunction · 0.85
temp_project_scopeFunction · 0.85
create_fileMethod · 0.45
idMethod · 0.45
delete_fileMethod · 0.45
create_folderMethod · 0.45
get_file_by_idMethod · 0.45
delete_folderMethod · 0.45

Tested by

no test coverage detected