mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Add ServeSession test for changing text file
This commit is contained in:
@@ -194,11 +194,13 @@ impl<F: ImfsFetcher> ServeSession<F> {
|
|||||||
mod serve_session {
|
mod serve_session {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
use std::{path::PathBuf, thread::sleep, time::Duration};
|
||||||
|
|
||||||
use insta::assert_yaml_snapshot;
|
use insta::assert_yaml_snapshot;
|
||||||
use rojo_insta_ext::RedactionMap;
|
use rojo_insta_ext::RedactionMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{ImfsDebug, ImfsSnapshot, NoopFetcher},
|
imfs::{ImfsDebug, ImfsEvent, ImfsSnapshot, NoopFetcher, TestFetcher},
|
||||||
tree_view::view_tree,
|
tree_view::view_tree,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -213,4 +215,26 @@ mod serve_session {
|
|||||||
let mut rm = RedactionMap::new();
|
let mut rm = RedactionMap::new();
|
||||||
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
|
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn change_txt_file() {
|
||||||
|
let (state, fetcher) = TestFetcher::new();
|
||||||
|
|
||||||
|
state.load_snapshot("/foo.txt", ImfsSnapshot::file("Hello!"));
|
||||||
|
|
||||||
|
let imfs = Imfs::new(fetcher);
|
||||||
|
let session = ServeSession::new(imfs, "/foo.txt", None);
|
||||||
|
|
||||||
|
let mut redactions = RedactionMap::new();
|
||||||
|
assert_yaml_snapshot!(view_tree(&session.tree(), &mut redactions));
|
||||||
|
|
||||||
|
state.load_snapshot("/foo.txt", ImfsSnapshot::file("World!"));
|
||||||
|
state.raise_event(ImfsEvent::Modified(PathBuf::from("/foo.txt")));
|
||||||
|
|
||||||
|
// TODO: Listen for a signal that the tree changed instead, using the
|
||||||
|
// message queue
|
||||||
|
sleep(Duration::from_millis(20));
|
||||||
|
|
||||||
|
assert_yaml_snapshot!(view_tree(&session.tree(), &mut redactions));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/snapshots/serve_session__change_txt_file-2.snap
Normal file
18
src/snapshots/serve_session__change_txt_file-2.snap
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
source: src/serve_session.rs
|
||||||
|
expression: "view_tree(&session.tree(), &mut redactions)"
|
||||||
|
---
|
||||||
|
id: id-1
|
||||||
|
name: foo
|
||||||
|
class_name: StringValue
|
||||||
|
properties:
|
||||||
|
Value:
|
||||||
|
Type: String
|
||||||
|
Value: World!
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
instigating_source:
|
||||||
|
Path: /foo.txt
|
||||||
|
relevant_paths:
|
||||||
|
- /foo.txt
|
||||||
|
children: []
|
||||||
18
src/snapshots/serve_session__change_txt_file.snap
Normal file
18
src/snapshots/serve_session__change_txt_file.snap
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
source: src/serve_session.rs
|
||||||
|
expression: "view_tree(&session.tree(), &mut redactions)"
|
||||||
|
---
|
||||||
|
id: id-1
|
||||||
|
name: foo
|
||||||
|
class_name: StringValue
|
||||||
|
properties:
|
||||||
|
Value:
|
||||||
|
Type: String
|
||||||
|
Value: Hello!
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
instigating_source:
|
||||||
|
Path: /foo.txt
|
||||||
|
relevant_paths:
|
||||||
|
- /foo.txt
|
||||||
|
children: []
|
||||||
Reference in New Issue
Block a user