mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-28 01:07:09 +00:00
Use scan_complete
and the new ModelHandle::condition
test method
This commit is contained in:
parent
d11d5483b6
commit
ebb7124405
1 changed files with 17 additions and 34 deletions
|
@ -955,7 +955,8 @@ mod tests {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx));
|
let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx));
|
||||||
assert_condition(1, 300, || app.read(|ctx| tree.read(ctx).file_count() == 1)).await;
|
app.read(|ctx| tree.read(ctx).scan_complete()).await;
|
||||||
|
app.read(|ctx| assert_eq!(tree.read(ctx).file_count(), 1));
|
||||||
|
|
||||||
let buffer = Buffer::new(1, "a line of text.\n".repeat(10 * 1024));
|
let buffer = Buffer::new(1, "a line of text.\n".repeat(10 * 1024));
|
||||||
|
|
||||||
|
@ -988,47 +989,29 @@ mod tests {
|
||||||
fn test_rescan() {
|
fn test_rescan() {
|
||||||
App::test_async((), |mut app| async move {
|
App::test_async((), |mut app| async move {
|
||||||
let dir = temp_tree(json!({
|
let dir = temp_tree(json!({
|
||||||
"dir1": {
|
"a": {
|
||||||
"file1": "contents 1",
|
"file1": "",
|
||||||
},
|
},
|
||||||
"dir2": {
|
"b": {
|
||||||
"dir3": {
|
"c": {
|
||||||
"file2": "contents 2",
|
"file2": "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx));
|
let tree = app.add_model(|ctx| Worktree::new(dir.path(), ctx));
|
||||||
assert_condition(1, 300, || app.read(|ctx| tree.read(ctx).file_count() == 2)).await;
|
app.read(|ctx| tree.read(ctx).scan_complete()).await;
|
||||||
|
app.read(|ctx| assert_eq!(tree.read(ctx).file_count(), 2));
|
||||||
|
|
||||||
let file2_inode = app.read(|ctx| {
|
let file2 = app.read(|ctx| {
|
||||||
tree.read(ctx)
|
let inode = tree.read(ctx).inode_for_path("b/c/file2").unwrap();
|
||||||
.snapshot()
|
let file2 = tree.file(inode, ctx).unwrap();
|
||||||
.inode_for_path("dir2/dir3/file2")
|
assert_eq!(file2.path(ctx), Path::new("b/c/file2"));
|
||||||
.unwrap()
|
file2
|
||||||
});
|
|
||||||
app.read(|ctx| {
|
|
||||||
let tree = tree.read(ctx);
|
|
||||||
assert_eq!(
|
|
||||||
tree.path_for_inode(file2_inode, false)
|
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap(),
|
|
||||||
"dir2/dir3/file2"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
std::fs::rename(dir.path().join("dir2/dir3"), dir.path().join("dir4")).unwrap();
|
std::fs::rename(dir.path().join("b/c"), dir.path().join("d")).unwrap();
|
||||||
assert_condition(1, 300, || {
|
tree.condition(&app, move |_, ctx| file2.path(ctx) == Path::new("d/file2"))
|
||||||
app.read(|ctx| {
|
|
||||||
let tree = tree.read(ctx);
|
|
||||||
tree.path_for_inode(file2_inode, false)
|
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
== "dir4/file2"
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.await;
|
.await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue