Compare commits
No commits in common. "master" and "fix-update-clap" have entirely different histories.
master
...
fix-update
@ -42,13 +42,10 @@ pub fn add(args: AddArgs) {
|
||||
let path = repo_root().join(Path::new(&f));
|
||||
match path.exists() {
|
||||
true => {
|
||||
let mut obj = Obj::from_path(f.clone());
|
||||
if obj.has_changes() {
|
||||
add_entry(path, args.force, &mut added_files, rules.clone(), &mut ignored_f);
|
||||
}
|
||||
},
|
||||
false => {
|
||||
if Obj::from_path(file.clone()).exists_on_remote() {
|
||||
if Object::new(path.to_str().unwrap()).exists() {
|
||||
// object is deleted so not present but can still be added for deletion
|
||||
added_files.push(String::from(f));
|
||||
} else {
|
||||
|
||||
@ -28,7 +28,7 @@ pub fn init() {
|
||||
path.push(".nextsync");
|
||||
match builder.create(path.clone()) {
|
||||
Ok(()) => (),
|
||||
Err(err) => println!("Error: cannot create .nextsync ({})", err),
|
||||
Err(_) => println!("Error: cannot create .nextsync"),
|
||||
};
|
||||
|
||||
path.push("objects");
|
||||
@ -59,12 +59,12 @@ pub fn init() {
|
||||
}
|
||||
|
||||
// todo
|
||||
// path.pop();
|
||||
// path.pop();
|
||||
// path.push(".nextsyncignore");
|
||||
//
|
||||
// match File::create(path) {
|
||||
// Ok(_) => (),
|
||||
// Err(_) => println!("Error: cannot create .nextsyncignore"),
|
||||
// }
|
||||
path.pop();
|
||||
path.pop();
|
||||
path.push(".nextsyncignore");
|
||||
|
||||
match File::create(path) {
|
||||
Ok(_) => (),
|
||||
Err(_) => println!("Error: cannot create .nextsyncignore"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,10 +71,9 @@ pub fn push() {
|
||||
},
|
||||
PushState::Done => remove_obj_from_index(obj.clone()),
|
||||
PushState::Conflict => {
|
||||
eprintln!("conflict when pushing blob");
|
||||
// download file
|
||||
}
|
||||
PushState::Error => (eprintln!("error when pushing changes blob")),
|
||||
PushState::Error => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ impl PushChange for Deleted {
|
||||
|
||||
// update tree
|
||||
// todo date
|
||||
Blob::from_path(obj.path.clone()).rm_node()?;
|
||||
Blob::from_path(obj.path.clone()).rm()?;
|
||||
|
||||
// remove index
|
||||
index::rm_line(obj.path.to_str().unwrap())?;
|
||||
|
||||
@ -73,16 +73,9 @@ pub trait PushChange {
|
||||
};
|
||||
|
||||
// check if remote is newest
|
||||
let last_sync_ts = {
|
||||
if obj.otype == String::from("blob") {
|
||||
Blob::from_path(obj.path.clone())
|
||||
let last_sync_ts = Blob::from_path(obj.path.clone())
|
||||
.saved_remote_ts()
|
||||
.parse::<i64>().unwrap()
|
||||
} else {
|
||||
// todo timestamp on tree
|
||||
99999999999999
|
||||
}
|
||||
};
|
||||
.parse::<i64>().unwrap();
|
||||
let remote_ts = obj_data.lastmodified.unwrap().timestamp_millis();
|
||||
|
||||
if last_sync_ts < remote_ts {
|
||||
|
||||
@ -160,8 +160,19 @@ pub struct LocalObj {
|
||||
}
|
||||
|
||||
pub fn get_all_staged() -> Vec<LocalObj> {
|
||||
let mut all_hashes = get_all_objs_hashes();
|
||||
get_staged(&mut all_hashes)
|
||||
let mut staged_objs = vec![];
|
||||
|
||||
if let Ok(entries) = index::read_line() {
|
||||
for line in entries {
|
||||
|
||||
let obj = Obj::from_path(line.unwrap()).get_local_obj();
|
||||
if obj.state != State::Default {
|
||||
staged_objs.push(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
staged_objs
|
||||
}
|
||||
|
||||
fn get_staged(hashes: &mut HashMap<String, LocalObj>) -> Vec<LocalObj> {
|
||||
|
||||
@ -26,13 +26,12 @@ pub trait ObjMethods {
|
||||
fn get_name(&self) -> String;
|
||||
fn get_hash_path(&self) -> String;
|
||||
fn get_local_obj(&self) -> LocalObj;
|
||||
fn get_line(&self, obj_type: ObjType) -> String;
|
||||
fn get_line(&self) -> String;
|
||||
fn add_ref_to_parent(&self) -> io::Result<()>;
|
||||
fn rm(&mut self) -> io::Result<()>;
|
||||
fn rm_node(&mut self) -> io::Result<()>;
|
||||
fn rm_node_down(&mut self) -> io::Result<()>;
|
||||
fn exists_on_remote(&mut self) -> bool;
|
||||
fn has_changes(&mut self) -> bool;
|
||||
}
|
||||
|
||||
pub struct Obj {
|
||||
@ -90,17 +89,12 @@ impl ObjMethods for Obj {
|
||||
}
|
||||
|
||||
// build line for parent reference
|
||||
fn get_line(&self, obj_type: ObjType) -> String {
|
||||
let type_str = match obj_type {
|
||||
ObjType::BLOB => "blob",
|
||||
ObjType::TREE => "tree",
|
||||
ObjType::DEFAULT => "default",
|
||||
};
|
||||
format!("{} {} {}", type_str, self.get_hash_path(), self.get_name())
|
||||
fn get_line(&self) -> String {
|
||||
format!("tree {} {}", self.get_hash_path(), self.get_name())
|
||||
}
|
||||
|
||||
fn add_ref_to_parent(&self) -> io::Result<()> {
|
||||
let line = self.get_line(self.obj_type);
|
||||
let line = self.get_line();
|
||||
if self.get_relative_file_path().iter().count() == 1 {
|
||||
head::add_line(line)?;
|
||||
} else {
|
||||
@ -110,8 +104,11 @@ impl ObjMethods for Obj {
|
||||
}
|
||||
|
||||
fn rm_node(&mut self) -> io::Result<()> {
|
||||
// remove self object and children object
|
||||
self.rm_node_down();
|
||||
|
||||
// remove parent reference to self
|
||||
let line = self.get_line(self.obj_type);
|
||||
let line = self.get_line();
|
||||
if self.get_relative_file_path().iter().count() == 1 {
|
||||
head::rm_line(&line)?;
|
||||
} else {
|
||||
@ -132,21 +129,7 @@ impl ObjMethods for Obj {
|
||||
}
|
||||
|
||||
fn exists_on_remote(&mut self) -> bool {
|
||||
self.obj_path.exists()
|
||||
}
|
||||
|
||||
fn has_changes(&mut self) -> bool {
|
||||
if !self.obj_path.exists() {
|
||||
return true;
|
||||
}
|
||||
|
||||
match self.obj_type {
|
||||
ObjType::BLOB => Blob::from_path(self.relative_file_path.clone()).has_changes(),
|
||||
ObjType::TREE => Tree::from_path(self.relative_file_path.clone()).has_changes(),
|
||||
ObjType::DEFAULT => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
PathBuf::from(self.get_hash_path()).exists()
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,8 +166,8 @@ impl ObjMethods for Blob {
|
||||
self.obj.get_hash_path()
|
||||
}
|
||||
|
||||
fn get_line(&self, _: ObjType) -> String {
|
||||
self.obj.get_line(ObjType::BLOB)
|
||||
fn get_line(&self) -> String {
|
||||
self.obj.get_line()
|
||||
}
|
||||
|
||||
fn add_ref_to_parent(&self) -> io::Result<()> {
|
||||
@ -192,8 +175,6 @@ impl ObjMethods for Blob {
|
||||
}
|
||||
|
||||
fn rm_node(&mut self) -> io::Result<()> {
|
||||
// remove self object and children object
|
||||
let _ = self.rm_node_down();
|
||||
self.obj.rm_node()
|
||||
}
|
||||
|
||||
@ -215,10 +196,6 @@ impl ObjMethods for Blob {
|
||||
fn exists_on_remote(&mut self) -> bool {
|
||||
self.obj.exists_on_remote()
|
||||
}
|
||||
|
||||
fn has_changes(&mut self) -> bool {
|
||||
self.obj.has_changes()
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjMethods for Tree {
|
||||
@ -254,8 +231,8 @@ impl ObjMethods for Tree {
|
||||
self.obj.get_hash_path()
|
||||
}
|
||||
|
||||
fn get_line(&self, _: ObjType) -> String {
|
||||
self.obj.get_line(ObjType::TREE)
|
||||
fn get_line(&self) -> String {
|
||||
self.obj.get_line()
|
||||
}
|
||||
|
||||
fn add_ref_to_parent(&self) -> io::Result<()> {
|
||||
@ -263,8 +240,6 @@ impl ObjMethods for Tree {
|
||||
}
|
||||
|
||||
fn rm_node(&mut self) -> io::Result<()> {
|
||||
// remove self object and children object
|
||||
let _ = self.rm_node_down();
|
||||
self.obj.rm_node()
|
||||
}
|
||||
|
||||
@ -296,10 +271,6 @@ impl ObjMethods for Tree {
|
||||
fn exists_on_remote(&mut self) -> bool {
|
||||
self.obj.exists_on_remote()
|
||||
}
|
||||
|
||||
fn has_changes(&mut self) -> bool {
|
||||
self.obj.has_changes()
|
||||
}
|
||||
}
|
||||
|
||||
impl Obj {
|
||||
@ -316,7 +287,6 @@ impl Obj {
|
||||
}
|
||||
|
||||
pub fn from_path<S>(path: S) -> Obj where S: IntoPathBuf {
|
||||
|
||||
let path = path.into();
|
||||
let mut hasher = Sha1::new();
|
||||
hasher.input_str(path.to_str().unwrap());
|
||||
@ -327,13 +297,8 @@ impl Obj {
|
||||
obj_path.push(dir);
|
||||
obj_path.push(res);
|
||||
|
||||
// set to absolute path if not already
|
||||
let root = path::repo_root();
|
||||
let abs_path = match path.clone().starts_with(root.clone()) {
|
||||
true => path.clone(),
|
||||
false => root.join(path.clone())
|
||||
};
|
||||
|
||||
let abs_path = root.join(path.clone());
|
||||
Obj {
|
||||
name: match abs_path.file_name() {
|
||||
None => String::new(),
|
||||
@ -356,9 +321,9 @@ impl Obj {
|
||||
|
||||
/// load from the information line stored in the object
|
||||
pub fn from_line(line: String, base_dir: Option<PathBuf>) -> Box<dyn ObjMethods> {
|
||||
let mut split = line.trim().rsplit(' ');
|
||||
let mut split = line.rsplit(' ');
|
||||
if split.clone().count() != 3 {
|
||||
eprintln!("fatal: invalid object(s) ({})", line.trim());
|
||||
eprintln!("fatal: invalid object(s)");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -42,20 +42,14 @@ impl Tree {
|
||||
if let Ok(file) = File::open(self.get_obj_path()) {
|
||||
self.buf_reader = Some(BufReader::new(file));
|
||||
|
||||
// skip first line (declaration) if is not head
|
||||
// skip first line if is head
|
||||
if !self.is_head {
|
||||
let mut line = String::new();
|
||||
self.buf_reader.as_mut().unwrap().read_line(&mut line);
|
||||
self.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_changes(&mut self) -> bool {
|
||||
todo!();
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn next(&mut self) -> Option<Box<dyn ObjMethods>> {
|
||||
self.read();
|
||||
//if let Some(ref mut file) = self.buf_reader {
|
||||
@ -105,11 +99,11 @@ impl Tree {
|
||||
.open(self.get_obj_path())?;
|
||||
|
||||
// update date for all parent
|
||||
// if up_parent {
|
||||
// if let Err(err) = update_dates(self.get_relative_file_path(), date) {
|
||||
// eprintln!("err: updating parent date of {}: {}", self.get_relative_file_path().display(), err);
|
||||
// }
|
||||
// }
|
||||
if up_parent {
|
||||
if let Err(err) = update_dates(self.get_relative_file_path(), date) {
|
||||
eprintln!("err: updating parent date of {}: {}", self.get_relative_file_path().display(), err);
|
||||
}
|
||||
}
|
||||
|
||||
writeln!(file, "{}", content)?;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use clap::{Arg, ArgMatches, Command, ArgAction};
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
|
||||
use crate::commands;
|
||||
use crate::commands::add::AddArgs;
|
||||
@ -7,7 +7,7 @@ pub fn create() -> Command {
|
||||
Command::new("add")
|
||||
.arg(
|
||||
Arg::new("files")
|
||||
.required_unless_present("all")
|
||||
.required(true)
|
||||
.conflicts_with("all")
|
||||
.num_args(1..)
|
||||
.value_name("FILE")
|
||||
@ -17,14 +17,12 @@ pub fn create() -> Command {
|
||||
Arg::new("force")
|
||||
.short('f')
|
||||
.long("force")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Allow adding otherwise ignored files."),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("all")
|
||||
.short('A')
|
||||
.long("all")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("This adds, modifies, and removes index entries to match the working tree"),
|
||||
)
|
||||
.about("Add changes to the index")
|
||||
@ -36,7 +34,7 @@ pub fn handler(args: &ArgMatches) {
|
||||
None => vec![],
|
||||
Some(vals) => vals.map(|s| s.to_string()).collect(),
|
||||
},
|
||||
force: *args.get_one::<bool>("force").unwrap(),
|
||||
all: *args.get_one::<bool>("all").unwrap(),
|
||||
force: args.contains_id("force"),
|
||||
all: args.contains_id("all"),
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use clap::{Arg, Command, ArgMatches, ArgAction};
|
||||
use clap::{Arg, Command, ArgMatches};
|
||||
|
||||
use crate::commands;
|
||||
use crate::commands::remote::RemoteArgs;
|
||||
@ -26,7 +26,6 @@ pub fn create() -> Command {
|
||||
Arg::new("verbose")
|
||||
.short('v')
|
||||
.long("verbose")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Be a little more verbose and show remote url after name.")
|
||||
)
|
||||
}
|
||||
@ -40,7 +39,7 @@ pub fn handler(args: &ArgMatches) {
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
commands::remote::remote_list(*args.get_one::<bool>("verbose").unwrap());
|
||||
commands::remote::remote_list(args.contains_id("verbose"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,9 +22,3 @@ impl IntoPathBuf for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoPathBuf for &str {
|
||||
fn into(self) -> PathBuf {
|
||||
PathBuf::from(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
tests/add.rs
19
tests/add.rs
@ -40,8 +40,6 @@ 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]
|
||||
@ -96,21 +94,4 @@ mod add_tests {
|
||||
client.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_file_no_changes() {
|
||||
// add a file push it and add it again
|
||||
let (mut client, mut server) = init_test();
|
||||
|
||||
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);
|
||||
|
||||
clean_test(client, &mut server)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
mod utils;
|
||||
use utils::{utils::*};
|
||||
use utils::{utils::*, server::ServerTest, client::ClientTest};
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
@ -8,7 +8,10 @@ mod pull_tests {
|
||||
|
||||
#[test]
|
||||
fn simple_pull() {
|
||||
let (mut client, mut server) = init_test();
|
||||
let id = get_random_test_id();
|
||||
let mut server = ServerTest::new(id.clone());
|
||||
server.init();
|
||||
let mut client = ClientTest::new(id).init();
|
||||
|
||||
let _ = server.add_file("file1", "foo");
|
||||
client.run_cmd_ok("pull");
|
||||
@ -16,12 +19,16 @@ mod pull_tests {
|
||||
// tests
|
||||
assert!(client.has_file("file1", "foo"));
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_pull_directory() {
|
||||
let (mut client, mut server) = init_test();
|
||||
let id = get_random_test_id();
|
||||
let mut server = ServerTest::new(id.clone());
|
||||
server.init();
|
||||
let mut client = ClientTest::new(id).init();
|
||||
|
||||
let _ = server.add_dir("dir");
|
||||
let _ = server.add_file("dir/file1", "foo");
|
||||
@ -31,6 +38,7 @@ mod pull_tests {
|
||||
// tests
|
||||
assert!(client.has_file("dir/file1", "foo"));
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,15 @@
|
||||
|
||||
mod utils;
|
||||
use utils::{utils::*, status_utils::*};
|
||||
use utils::{utils::*, status_utils::*, server::ServerTest, client::ClientTest};
|
||||
|
||||
fn init_test() -> (ClientTest, ServerTest) {
|
||||
let id = get_random_test_id();
|
||||
let mut server = ServerTest::new(id.clone());
|
||||
server.init();
|
||||
let client = ClientTest::new(id).init();
|
||||
(client, server)
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod push_tests {
|
||||
@ -19,7 +29,8 @@ mod push_tests {
|
||||
lines_should_not_contains(staged, "file1");
|
||||
lines_should_not_contains(not_staged, "file1");
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -49,7 +60,9 @@ mod push_tests {
|
||||
lines_should_not_contains(staged, "file1");
|
||||
lines_should_not_contains(not_staged, "file1");
|
||||
|
||||
clean_test(client, &mut server);
|
||||
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -71,7 +84,8 @@ mod push_tests {
|
||||
lines_should_not_contains(not_staged.clone(), "file2");
|
||||
lines_should_not_contains(not_staged, "foo");
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -93,7 +107,8 @@ mod push_tests {
|
||||
lines_should_not_contains(not_staged.clone(), "file2");
|
||||
lines_should_not_contains(not_staged, "foo");
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -115,7 +130,8 @@ mod push_tests {
|
||||
assert!(staged.len() == 0);
|
||||
assert!(not_staged.len() == 0);
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -135,34 +151,14 @@ mod push_tests {
|
||||
// remove it
|
||||
let _ = client.remove_file("file1");
|
||||
client.run_cmd_ok("add file1");
|
||||
dbg!(client.get_status());
|
||||
client.run_cmd_ok("push");
|
||||
|
||||
// tests
|
||||
assert!(server.has_not_file("file1"));
|
||||
status_should_be_empty(&mut client);
|
||||
|
||||
clean_test(client, &mut server);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn push_dir_deletion() {
|
||||
let (mut client, mut server) = init_test();
|
||||
|
||||
// push dir and file2
|
||||
let _ = client.add_dir("dir");
|
||||
let _ = client.add_file("dir/file2", "bar");
|
||||
client.run_cmd_ok("add dir");
|
||||
client.run_cmd_ok("push");
|
||||
|
||||
// tests
|
||||
assert!(server.has_file("dir/file2", "bar"));
|
||||
|
||||
// push deletion
|
||||
let _ = client.remove_dir("dir");
|
||||
client.run_cmd_ok("add dir");
|
||||
client.run_cmd_ok("push");
|
||||
assert!(server.has_not_dir("dir"));
|
||||
|
||||
clean_test(client, &mut server);
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,15 +100,8 @@ impl ClientTest {
|
||||
let mut path = self.volume.clone();
|
||||
path.push_str("/");
|
||||
path.push_str(name);
|
||||
fs::remove_file(path)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn remove_dir(&mut self, name: &str) -> std::io::Result<()> {
|
||||
let mut path = self.volume.clone();
|
||||
path.push_str("/");
|
||||
path.push_str(name);
|
||||
fs::remove_dir_all(path)?;
|
||||
fs::remove_file(name)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@ -36,15 +36,3 @@ pub fn has_not_file(full_path: PathBuf, file: &str, test_id: String) -> bool
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn has_not_dir(full_path: PathBuf, dir: &str, test_id: String) -> bool
|
||||
{
|
||||
if full_path.exists() {
|
||||
println!("id: {}", test_id.clone());
|
||||
eprintln!("Dir '{}' exists but it shouldn't", dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -113,11 +113,5 @@ impl ServerTest {
|
||||
let full_path = self.volume.clone().join(file);
|
||||
files_utils::has_not_file(full_path, file, self.test_id.clone())
|
||||
}
|
||||
|
||||
pub fn has_not_dir(&mut self, dir: &str) -> bool {
|
||||
let full_path = self.volume.clone().join(dir);
|
||||
dbg!(full_path.clone());
|
||||
files_utils::has_not_file(full_path, dir, self.test_id.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 '{}' line(s)", staged.len());
|
||||
eprintln!("Staged should be empty but has '{}'", staged.len());
|
||||
assert!(staged.len() == 0);
|
||||
}
|
||||
|
||||
if staged.len() != 0 {
|
||||
eprintln!("id: {}", client.test_id.clone());
|
||||
eprintln!("Not Staged should be empty but has '{}' line(s)", not_staged.len());
|
||||
eprintln!("Not Staged should be empty but has '{}'", not_staged.len());
|
||||
assert!(not_staged.len() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
use rand::{distributions::Alphanumeric, Rng};
|
||||
use super::client::ClientTest;
|
||||
use super::server::ServerTest;
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn get_random_test_id() -> String {
|
||||
@ -12,20 +10,3 @@ pub fn get_random_test_id() -> String {
|
||||
id.push_str("_nextsync");
|
||||
id.to_owned()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn init_test() -> (ClientTest, ServerTest) {
|
||||
|
||||
let id = get_random_test_id();
|
||||
let mut server = ServerTest::new(id.clone());
|
||||
server.init();
|
||||
let client = ClientTest::new(id).init();
|
||||
(client, server)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn clean_test(client: ClientTest, server: &mut ServerTest) {
|
||||
client.clean();
|
||||
server.clean();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user