test(push): check that object are locally created when pushed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
9
tests/utils/status_utils.rs
Normal file
9
tests/utils/status_utils.rs
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user