aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests/integration/write.rs
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-04-30 04:35:00 +0000
committerSkyler Hawthorne2022-06-19 03:57:47 +0000
commitacf931709a56e5af0ac101276fcfb3ba45f159f2 (patch)
tree5782cd8e5d4f2891c18c8e1039e2c5dc04851c76 /helix-term/tests/integration/write.rs
parentef8fe5a5ce536c65f34e479db79b94c8435aa3b2 (diff)
use a read only file to ensure write failure
Diffstat (limited to 'helix-term/tests/integration/write.rs')
-rw-r--r--helix-term/tests/integration/write.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/helix-term/tests/integration/write.rs b/helix-term/tests/integration/write.rs
index 06af9dd8..f3abbd91 100644
--- a/helix-term/tests/integration/write.rs
+++ b/helix-term/tests/integration/write.rs
@@ -75,10 +75,12 @@ async fn test_write_concurrent() -> anyhow::Result<()> {
#[tokio::test]
async fn test_write_fail_mod_flag() -> anyhow::Result<()> {
+ let file = helpers::new_readonly_tempfile()?;
+
test_key_sequences(
&mut Application::new(
Args {
- files: vec![(PathBuf::from("/foo"), Position::default())],
+ files: vec![(file.path().to_path_buf(), Position::default())],
..Default::default()
},
Config::default(),
@@ -116,6 +118,8 @@ async fn test_write_fail_mod_flag() -> anyhow::Result<()> {
#[tokio::test]
async fn test_write_fail_new_path() -> anyhow::Result<()> {
+ let file = helpers::new_readonly_tempfile()?;
+
test_key_sequences(
&mut Application::new(Args::default(), Config::default())?,
vec![
@@ -123,15 +127,21 @@ async fn test_write_fail_new_path() -> anyhow::Result<()> {
None,
Some(&|app| {
let doc = doc!(app.editor);
- assert_eq!(None, app.editor.get_status());
+ assert_ne!(
+ Some(&Severity::Error),
+ app.editor.get_status().map(|status| status.1)
+ );
assert_eq!(None, doc.path());
}),
),
(
- Some(":w /foo<ret>"),
+ Some(&format!(":w {}<ret>", file.path().to_string_lossy())),
Some(&|app| {
let doc = doc!(app.editor);
- assert_eq!(&Severity::Error, app.editor.get_status().unwrap().1);
+ assert_eq!(
+ Some(&Severity::Error),
+ app.editor.get_status().map(|status| status.1)
+ );
assert_eq!(None, doc.path());
}),
),