test(push): check that object are locally created when pushed

This commit is contained in:
grimhilt
2024-03-10 23:06:32 +01:00
parent fa65b6b071
commit 3207391fdb
5 changed files with 77 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
use std::str;
use std::process::{Command, Output};
use std::fs::{self, File};
use std::io::Write;
@@ -90,4 +91,46 @@ impl ClientTest {
file.write_all(content.as_bytes())?;
Ok(())
}
/// get the files given by the status command in two vector (staged and not staged)
pub fn get_status(&mut self) -> (Vec<String>, Vec<String>) {
let out = self.run_cmd("status");
let lines: Vec<String> = str::from_utf8(&out.stdout)
.unwrap()
.split("\n")
.map(|s| s.to_owned())
.collect();
let mut staged = vec![];
let mut not_staged = vec![];
let mut in_staged = true;
let mut counter = 0;
for line in lines {
if line.find("not staged").is_some() {
in_staged = false;
counter = 1;
continue;
}
// skip two first line as there are not files
if counter < 2 {
counter += 1;
continue;
}
if line == String::from("") {
continue;
}
if in_staged {
staged.push(line);
} else {
not_staged.push(line);
}
}
return (staged, not_staged);
}
}

View File

@@ -0,0 +1,9 @@
pub fn lines_should_not_contains(lines: Vec<String>, str: &str) {
for line in lines {
if line.find(str).is_some() {
eprintln!("'{}' found in '{}'", str, line);
}
assert!(line.find(str).is_none());
}
}