Add ServeSession test for project with folder

This commit is contained in:
Lucien Greathouse
2019-10-08 13:57:40 -07:00
parent 4e47655b17
commit 3bd8549f41
2 changed files with 58 additions and 0 deletions

View File

@@ -197,6 +197,7 @@ mod serve_session {
use std::{path::PathBuf, time::Duration};
use insta::assert_yaml_snapshot;
use maplit::hashmap;
use rojo_insta_ext::RedactionMap;
use tokio::{runtime::Runtime, timer::Timeout};
@@ -217,6 +218,33 @@ mod serve_session {
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
}
#[test]
fn project_with_folder() {
let mut imfs = Imfs::new(NoopFetcher);
imfs.debug_load_snapshot(
"/foo",
ImfsSnapshot::dir(hashmap! {
"default.project.json" => ImfsSnapshot::file(r#"
{
"name": "HelloWorld",
"tree": {
"$path": "src"
}
}
"#),
"src" => ImfsSnapshot::dir(hashmap! {
"hello.txt" => ImfsSnapshot::file("Hello, world!"),
}),
}),
);
let session = ServeSession::new(imfs, "/foo", None);
let mut rm = RedactionMap::new();
assert_yaml_snapshot!(view_tree(&session.tree(), &mut rm));
}
#[test]
fn change_txt_file() {
let (state, fetcher) = TestFetcher::new();

View File

@@ -0,0 +1,30 @@
---
source: src/serve_session.rs
expression: "view_tree(&session.tree(), &mut rm)"
---
id: id-1
name: HelloWorld
class_name: Folder
properties: {}
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /foo/default.project.json
relevant_paths:
- /foo/src
- /foo/default.project.json
children:
- id: id-2
name: hello
class_name: StringValue
properties:
Value:
Type: String
Value: "Hello, world!"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /foo/src/hello.txt
relevant_paths:
- /foo/src/hello.txt
children: []