This commit is contained in:
@@ -175,6 +175,42 @@ async fn filesystem_permissions_and_public_sharing() {
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn config_is_shared_writable_and_survives_host_restart() {
|
||||
let (world, host, mut mailbox) = filesystem_world("world-config").await;
|
||||
let path = "/config/global.json";
|
||||
let first = r#"{"model":"first"}"#;
|
||||
let second = r#"{"model":"second"}"#;
|
||||
ask_type(
|
||||
&host, &mut mailbox, "writer",
|
||||
json!({"type": "write", "path": path, "text": first}), "ok",
|
||||
).await;
|
||||
let read = ask_type(
|
||||
&host, &mut mailbox, "reader",
|
||||
json!({"type": "read", "path": path}), "content",
|
||||
).await;
|
||||
assert_eq!(read.body["text"], first);
|
||||
// The second actor can replace the same file too.
|
||||
ask_type(
|
||||
&host, &mut mailbox, "reader",
|
||||
json!({"type": "write", "path": path, "text": second}), "ok",
|
||||
).await;
|
||||
assert_eq!(std::fs::read_to_string(world.config_dir().join("global.json")).unwrap(), second);
|
||||
assert_eq!(world.resolve("writer", path).unwrap(), world.config_dir().join("global.json"));
|
||||
assert_eq!(world.resolve("console", path).unwrap(), world.config_dir().join("global.json"));
|
||||
host.stop().await;
|
||||
|
||||
let (host, mut mailbox) = start(&world).await;
|
||||
for actor in ["writer", "reader"] {
|
||||
let read = ask_type(
|
||||
&host, &mut mailbox, actor,
|
||||
json!({"type": "read", "path": path}), "content",
|
||||
).await;
|
||||
assert_eq!(read.body["text"], second);
|
||||
}
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn actors_can_read_but_not_write_other_actor_data() {
|
||||
let (_, host, mut mailbox) = filesystem_world("actor-data-sharing").await;
|
||||
|
||||
Reference in New Issue
Block a user