Skip to content

Commit 78d4b35

Browse files
Fix cross-platform Slack connector CI tests
1 parent 0492201 commit 78d4b35

2 files changed

Lines changed: 65 additions & 6 deletions

File tree

apps/desktop/src-tauri/src/main.rs

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12676,17 +12676,60 @@ mod tests {
1267612676
}
1267712677

1267812678
#[test]
12679-
fn create_desktop_mount_blocking_persists_slack_as_read_only_with_default_settings() {
12680-
let _lock = state_root_env_lock().lock().expect("state root env lock");
12679+
fn slack_desktop_mount_persists_read_only_with_default_settings() {
1268112680
let temp = TestTempDir::new("desktop-slack-mount-safety");
1268212681
let state_root = temp.path().join(".loc");
1268312682
let shared_root = temp.path().join("Locality");
1268412683
let mount_root = shared_root.join("slack");
1268512684
fs::create_dir_all(&shared_root).expect("create shared mount root");
1268612685
let mount_id = MountId::new("slack-main");
12686+
let settings_json = SlackMountSettings::default()
12687+
.to_json()
12688+
.expect("serialize default Slack settings");
12689+
let mut store = SqliteStateStore::open(state_root.clone()).expect("open state store");
12690+
12691+
super::run_mount(
12692+
&mut store,
12693+
super::MountOptions {
12694+
mount_id: mount_id.clone(),
12695+
connector: SLACK_CONNECTOR_ID.to_string(),
12696+
root: mount_root.clone(),
12697+
remote_root_id: None,
12698+
connection_id: None,
12699+
read_only: true,
12700+
projection: super::desktop_projection_mode(),
12701+
settings_json: settings_json.clone(),
12702+
},
12703+
)
12704+
.expect("persist Slack mount");
12705+
12706+
let mount = store
12707+
.get_mount(&mount_id)
12708+
.expect("load persisted Slack mount")
12709+
.expect("Slack mount persisted");
12710+
12711+
assert_eq!(mount.mount_id, mount_id);
12712+
assert_eq!(mount.connector, SLACK_CONNECTOR_ID);
12713+
assert_eq!(mount.root, mount_root);
12714+
assert_eq!(mount.connection_id, None);
12715+
assert_eq!(mount.remote_root_id, None);
12716+
assert!(mount.read_only);
12717+
assert_eq!(mount.settings_json, settings_json);
12718+
}
12719+
12720+
#[cfg(not(target_os = "macos"))]
12721+
#[test]
12722+
fn create_desktop_mount_blocking_for_slack_coerces_read_only_and_default_settings() {
12723+
let _lock = state_root_env_lock().lock().expect("state root env lock");
12724+
let temp = TestTempDir::new("desktop-slack-mount-request");
12725+
let state_root = temp.path().join(".loc");
12726+
let shared_root = temp.path().join("Locality");
12727+
let mount_root = shared_root.join("slack");
12728+
fs::create_dir_all(&shared_root).expect("create shared mount root");
12729+
let mount_id = MountId::new("slack-main");
1268712730
let state_root_guard = LocalityStateDirGuard::set(&state_root);
1268812731

12689-
let _ = super::create_desktop_mount_blocking(super::CreateDesktopMountRequest {
12732+
let result = super::create_desktop_mount_blocking(super::CreateDesktopMountRequest {
1269012733
connector: SLACK_CONNECTOR_ID.to_string(),
1269112734
path: mount_root.display().to_string(),
1269212735
mount_id: mount_id.0.clone(),
@@ -12695,13 +12738,22 @@ mod tests {
1269512738
notion_root_page: Some("should-not-be-used".to_string()),
1269612739
google_docs_workspace_folder: Some("should-not-be-used".to_string()),
1269712740
});
12741+
12742+
if let Err(error) = &result {
12743+
assert!(
12744+
error.contains("locality-fuse was not found")
12745+
|| error.contains("locality-cloud-files")
12746+
|| error.contains("Windows Cloud Files"),
12747+
"unexpected Slack desktop mount error: {error}"
12748+
);
12749+
}
1269812750
drop(state_root_guard);
1269912751

1270012752
let store = SqliteStateStore::open(state_root.clone()).expect("open state store");
1270112753
let mount = store
1270212754
.get_mount(&mount_id)
1270312755
.expect("load persisted Slack mount")
12704-
.expect("Slack mount persisted before provider activation");
12756+
.expect("Slack mount persisted");
1270512757

1270612758
assert_eq!(mount.mount_id, mount_id);
1270712759
assert_eq!(mount.connector, SLACK_CONNECTOR_ID);

crates/loc-cli/tests/info.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ fn info_for_linux_fuse_reports_entity_absolute_path_under_mount_point_root() {
248248
fn targeted_info_uses_matched_access_root_for_entity_and_schema_paths() {
249249
let mut store = InMemoryStateStore::new();
250250
let mount_id = MountId::new("notion-main");
251-
let mount = MountConfig::new(mount_id.clone(), "notion", PathBuf::from("/"))
251+
#[cfg(windows)]
252+
let mount_root = PathBuf::from(r"C:\");
253+
#[cfg(not(windows))]
254+
let mount_root = PathBuf::from("/");
255+
let mount = MountConfig::new(mount_id.clone(), "notion", mount_root)
252256
.projection(ProjectionMode::LinuxFuse);
253257
store.save_mount(mount.clone()).expect("save mount");
254258
store
@@ -261,7 +265,10 @@ fn targeted_info_uses_matched_access_root_for_entity_and_schema_paths() {
261265
))
262266
.expect("save database");
263267

264-
let access_root = PathBuf::from("/notion-main");
268+
let access_root = localityd::file_provider::mount_access_roots(&mount)
269+
.into_iter()
270+
.find(|root| root != &mount.root)
271+
.expect("virtual access root");
265272
let report = run_info(
266273
&store,
267274
InfoOptions {

0 commit comments

Comments
 (0)