summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-02-07 10:21:38 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-02-07 10:22:07 +0000
commit744e0ef7d5bbae168e6225d8de2d07ade7f417f5 (patch)
tree4b9c784ce4195cfb1ac16d4e7973ae3fce913858 /subplotlib
parenteb4c7ce8a34fbc963554da1613bcc081571411ad (diff)
downloadsubplot-744e0ef7d5bbae168e6225d8de2d07ade7f417f5.tar.gz
subplotlib: test the new directory steps
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/files.md24
-rw-r--r--subplotlib/tests/files.rs141
2 files changed, 165 insertions, 0 deletions
diff --git a/subplotlib/files.md b/subplotlib/files.md
index d005be5..56bea41 100644
--- a/subplotlib/files.md
+++ b/subplotlib/files.md
@@ -75,3 +75,27 @@ then file hello.txt contains "hello, world"
and file hello.txt matches regex "hello, .*"
and file hello.txt matches regex /hello, .*/
```
+
+# Directories
+
+There are also a large number of directory based steps and some directory
+based behaviour available in creating files which are available in the files
+library.
+
+```scenario
+given a directory first
+then directory first exists
+and directory first is empty
+and directory second does not exist
+when I remove directory first
+then directory first does not exist
+when I create directory second
+then directory second exists
+and directory second is empty
+given file second/third/hello.txt from hello.txt
+then directory second is not empty
+and directory second/third exists
+and directory second/third is not empty
+when I remove directory second
+then directory second does not exist
+```
diff --git a/subplotlib/tests/files.rs b/subplotlib/tests/files.rs
index 8b3ba41..a8fce3d 100644
--- a/subplotlib/tests/files.rs
+++ b/subplotlib/tests/files.rs
@@ -273,3 +273,144 @@ fn file_contents() {
scenario.run().unwrap();
}
+
+// ---------------------------------
+
+// Directories
+#[test]
+fn directories() {
+ let mut scenario = Scenario::new(&base64_decode("RGlyZWN0b3JpZXM="));
+
+ let step = subplotlib::steplibrary::files::make_directory::Builder::default()
+ .path(
+ // "first"
+ &base64_decode("Zmlyc3Q="),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_exists::Builder::default()
+ .path(
+ // "first"
+ &base64_decode("Zmlyc3Q="),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_is_empty::Builder::default()
+ .path(
+ // "first"
+ &base64_decode("Zmlyc3Q="),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_does_not_exist::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::remove_directory::Builder::default()
+ .path(
+ // "first"
+ &base64_decode("Zmlyc3Q="),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_does_not_exist::Builder::default()
+ .path(
+ // "first"
+ &base64_decode("Zmlyc3Q="),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::make_directory::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_exists::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_is_empty::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step =
+ subplotlib::steplibrary::files::create_from_embedded_with_other_name::Builder::default()
+ .filename_on_disk(
+ // "second/third/hello.txt"
+ &base64_decode("c2Vjb25kL3RoaXJkL2hlbGxvLnR4dA=="),
+ )
+ .embedded_file({
+ use std::path::PathBuf;
+ // hello.txt
+ let target_name: PathBuf = base64_decode("aGVsbG8udHh0").into();
+ SUBPLOT_EMBEDDED_FILES
+ .iter()
+ .find(|df| df.name() == target_name)
+ .expect("Unable to find file at runtime")
+ .clone()
+ })
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_is_not_empty::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_exists::Builder::default()
+ .path(
+ // "second/third"
+ &base64_decode("c2Vjb25kL3RoaXJk"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_is_not_empty::Builder::default()
+ .path(
+ // "second/third"
+ &base64_decode("c2Vjb25kL3RoaXJk"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::remove_directory::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ let step = subplotlib::steplibrary::files::path_does_not_exist::Builder::default()
+ .path(
+ // "second"
+ &base64_decode("c2Vjb25k"),
+ )
+ .build();
+ scenario.add_step(step, None);
+
+ scenario.run().unwrap();
+}