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 4, 2022
1 parent f68eed6 commit 504b26f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions helix-term/tests/test/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,38 @@ 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>",
std::fs::canonicalize(output_file.path()).unwrap()
);
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 504b26f

Please sign in to comment.