74 lines
1.6 KiB
Rust
74 lines
1.6 KiB
Rust
use std::str;
|
|
|
|
mod utils;
|
|
use utils::{utils::*, client::ClientTest};
|
|
|
|
fn line_should_contains(line: &str, str: &str) {
|
|
|
|
if line.find(str).is_none()
|
|
{
|
|
eprintln!("'{}' not found in '{}'", str, line);
|
|
}
|
|
|
|
assert!(line.find(str).is_some());
|
|
}
|
|
|
|
fn lines_should_not_contains(lines: Vec<&str>, str: &str) {
|
|
|
|
for line in lines {
|
|
if line.find("Changes not staged for push").is_some() {
|
|
return;
|
|
}
|
|
|
|
if line.find(str).is_some() {
|
|
eprintln!("'{}' found in '{}'", str, line);
|
|
}
|
|
assert!(line.find(str).is_none());
|
|
}
|
|
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod push_tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn simple_add() {
|
|
let id = get_random_test_id();
|
|
let mut client = ClientTest::new(id).init();
|
|
|
|
let _ = client.add_file("file1", "foo");
|
|
client.run_cmd_ok("add file1");
|
|
|
|
let out = client.run_cmd("status");
|
|
let lines: Vec<&str> = str::from_utf8(&out.stdout)
|
|
.unwrap()
|
|
.split("\n")
|
|
.collect();
|
|
|
|
line_should_contains(lines[2], "file1");
|
|
|
|
client.clean();
|
|
}
|
|
|
|
#[test]
|
|
fn add_config_file() {
|
|
let id = get_random_test_id();
|
|
let mut client = ClientTest::new(id).init();
|
|
|
|
let _ = client.add_file("file1", "foo");
|
|
client.run_cmd_ok("add .nextsync -f");
|
|
|
|
let out = client.run_cmd("status");
|
|
let lines: Vec<&str> = str::from_utf8(&out.stdout)
|
|
.unwrap()
|
|
.split("\n")
|
|
.collect();
|
|
|
|
lines_should_not_contains(lines, ".nextsync");
|
|
|
|
client.clean();
|
|
}
|
|
|
|
}
|