Skip to content

Commit b5d9ce2

Browse files
committed
fix(test): correct logic causing test discard to fail
1 parent 8b0bc26 commit b5d9ce2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

asyncgit/src/sync/status.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,24 @@ pub fn discard_status(repo_path: &RepoPath) -> Result<bool> {
282282
#[cfg(test)]
283283
mod tests {
284284
use super::*;
285-
use crate::sync::tests::repo_init;
285+
use crate::sync::{commit, stage_add_file, tests::repo_init};
286286
use std::{fs::File, io::Write, path::Path};
287287

288288
#[test]
289289
fn test_discard_status() {
290-
let file_path = Path::new("foo");
290+
let file_path = Path::new("README.md");
291291
let (_td, repo) = repo_init().unwrap();
292292
let root = repo.path().parent().unwrap();
293293
let repo_path: &RepoPath =
294294
&root.as_os_str().to_str().unwrap().into();
295295

296-
File::create(root.join(file_path))
297-
.unwrap()
298-
.write_all(b"test\nfoo")
299-
.unwrap();
296+
let mut file = File::create(root.join(file_path)).unwrap();
297+
298+
// initial commit
299+
stage_add_file(repo_path, file_path).unwrap();
300+
commit(repo_path, "commit msg").unwrap();
301+
302+
writeln!(file, "Test for discard_status").unwrap();
300303

301304
let statuses =
302305
get_status(repo_path, StatusType::WorkingDir, None)

0 commit comments

Comments
 (0)