feat(add): prevent adding a file without changes

This commit is contained in:
grimhilt
2024-05-07 18:12:05 +02:00
parent 939b6f2fe3
commit 980d2d9a5d
5 changed files with 54 additions and 10 deletions

View File

@@ -40,6 +40,8 @@ fn collect_status_lines(client: &mut ClientTest) -> Vec<String> {
#[cfg(test)]
mod add_tests {
use crate::utils::{server::ServerTest, status_utils::status_should_be_empty};
use super::*;
#[test]
@@ -95,14 +97,24 @@ mod add_tests {
}
#[test]
fn add_no_change() {
assert!(false);
fn add_file_no_changes() {
// add a file push it and add it again
// let id = get_random_test_id();
// let mut client = ClientTest::new(id).init();
//
//
// client.clean();
let id = get_random_test_id();
let mut server = ServerTest::new(id.clone());
server.init();
let mut client = ClientTest::new(id).init();
let _ = client.add_file("file1", "foo");
client.run_cmd_ok("add file1");
client.run_cmd_ok("push");
status_should_be_empty(&mut client);
client.run_cmd_ok("add file1");
status_should_be_empty(&mut client);
client.clean();
server.clean();
}
}

View File

@@ -15,13 +15,13 @@ pub fn status_should_be_empty(client: &mut ClientTest) {
let (staged, not_staged) = client.get_status();
if staged.len() != 0 {
eprintln!("id: {}", client.test_id.clone());
eprintln!("Staged should be empty but has '{}'", staged.len());
eprintln!("Staged should be empty but has '{}' line(s)", staged.len());
assert!(staged.len() == 0);
}
if staged.len() != 0 {
eprintln!("id: {}", client.test_id.clone());
eprintln!("Not Staged should be empty but has '{}'", not_staged.len());
eprintln!("Not Staged should be empty but has '{}' line(s)", not_staged.len());
assert!(not_staged.len() == 0);
}
}