Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
idursun committed Oct 5, 2022
1 parent e4c97bd commit e3cf0cc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions helix-term/tests/test/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,35 @@ async fn test_write_quit_fail() -> anyhow::Result<()> {
Ok(())
}

#[tokio::test]
async fn test_read_file() -> anyhow::Result<()> {
let mut file = tempfile::NamedTempFile::new()?;
let expected_content = String::from("some contents");
let output_file = helpers::temp_file_with_contents(&expected_content)?;
let mut command = String::new();
let cmd = format!(":r {:?}<ret><esc>:w<ret>", output_file.path());
command.push_str(&cmd);

test_key_sequence(
&mut helpers::app_with_file(file.path())?,
Some(&command),
Some(&|app| {
assert!(!app.editor.is_err(), "error: {:?}", app.editor.get_status());
}),
false,
)
.await?;

file.as_file_mut().flush()?;
file.as_file_mut().sync_all()?;

let mut file_content = String::new();
file.as_file_mut().read_to_string(&mut file_content)?;
assert_eq!(expected_content, file_content);

Ok(())
}

#[tokio::test]
#[ignore]
async fn test_buffer_close_concurrent() -> anyhow::Result<()> {
Expand Down

0 comments on commit e3cf0cc

Please sign in to comment.