Add debugging output in tests
This commit is contained in:
parent
103a0dea17
commit
74a9b844ca
3 changed files with 22 additions and 5 deletions
|
@ -4,9 +4,9 @@ version = "0.1.0"
|
||||||
authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.3.5"
|
|
||||||
fs2 = "0.2.2"
|
fs2 = "0.2.2"
|
||||||
glob = "0.2.10"
|
glob = "0.2.10"
|
||||||
|
log = "0.3.5"
|
||||||
regex = "0.1.47"
|
regex = "0.1.47"
|
||||||
semver = "0.2"
|
semver = "0.2"
|
||||||
toml = "0.1.25"
|
toml = "0.1.25"
|
||||||
|
@ -14,3 +14,5 @@ version = "2.0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3.4"
|
tempdir = "0.3.4"
|
||||||
|
env_logger = "0.3"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[macro_use] extern crate version;
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
#[macro_use] extern crate version;
|
||||||
extern crate fs2;
|
extern crate fs2;
|
||||||
extern crate glob;
|
extern crate glob;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
|
@ -492,12 +492,14 @@ impl EntryHeader {
|
||||||
return Err(tokens.err().unwrap());
|
return Err(tokens.err().unwrap());
|
||||||
}
|
}
|
||||||
let tokens = tokens.unwrap();
|
let tokens = tokens.unwrap();
|
||||||
|
debug!("tokens = {:?}", tokens);
|
||||||
|
|
||||||
let destination = tokens.iter().last();
|
let destination = tokens.iter().last();
|
||||||
if destination.is_none() {
|
if destination.is_none() {
|
||||||
return Err(StoreError::new(StoreErrorKind::HeaderPathSyntaxError, None));
|
return Err(StoreError::new(StoreErrorKind::HeaderPathSyntaxError, None));
|
||||||
}
|
}
|
||||||
let destination = destination.unwrap();
|
let destination = destination.unwrap();
|
||||||
|
debug!("destination = {:?}", destination);
|
||||||
|
|
||||||
let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens
|
let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens
|
||||||
let mut table = Value::Table(self.toml.clone()); // oh fuck, but yes, we clone() here
|
let mut table = Value::Table(self.toml.clone()); // oh fuck, but yes, we clone() here
|
||||||
|
@ -506,6 +508,7 @@ impl EntryHeader {
|
||||||
return Err(value.err().unwrap());
|
return Err(value.err().unwrap());
|
||||||
}
|
}
|
||||||
let mut value = value.unwrap();
|
let mut value = value.unwrap();
|
||||||
|
debug!("walked value = {:?}", value);
|
||||||
|
|
||||||
match destination {
|
match destination {
|
||||||
&Token::Key(ref s) => { // if the destination shall be an map key->value
|
&Token::Key(ref s) => { // if the destination shall be an map key->value
|
||||||
|
@ -514,13 +517,17 @@ impl EntryHeader {
|
||||||
* Put it in there if we have a map
|
* Put it in there if we have a map
|
||||||
*/
|
*/
|
||||||
&mut Value::Table(ref mut t) => {
|
&mut Value::Table(ref mut t) => {
|
||||||
|
debug!("Matched Key->Table");
|
||||||
return Ok(t.insert(s.clone(), v));
|
return Ok(t.insert(s.clone(), v));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fail if there is no map here
|
* Fail if there is no map here
|
||||||
*/
|
*/
|
||||||
_ => return Err(StoreError::new(StoreErrorKind::HeaderPathTypeFailure, None)),
|
_ => {
|
||||||
|
debug!("Matched Key->NON-Table");
|
||||||
|
return Err(StoreError::new(StoreErrorKind::HeaderPathTypeFailure, None));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -531,21 +538,27 @@ impl EntryHeader {
|
||||||
* Put it in there if we have an array
|
* Put it in there if we have an array
|
||||||
*/
|
*/
|
||||||
&mut Value::Array(ref mut a) => {
|
&mut Value::Array(ref mut a) => {
|
||||||
|
debug!("Matched Index->Array");
|
||||||
a.push(v); // push to the end of the array
|
a.push(v); // push to the end of the array
|
||||||
|
|
||||||
// if the index is inside the array, we swap-remove the element at this
|
// if the index is inside the array, we swap-remove the element at this
|
||||||
// index
|
// index
|
||||||
if a.len() < i {
|
if a.len() > i {
|
||||||
|
debug!("Swap-Removing in Array {:?}[{:?}] <- {:?}", a, i, a[a.len()-1]);
|
||||||
return Ok(Some(a.swap_remove(i)));
|
return Ok(Some(a.swap_remove(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug!("Appended");
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fail if there is no array here
|
* Fail if there is no array here
|
||||||
*/
|
*/
|
||||||
_ => return Err(StoreError::new(StoreErrorKind::HeaderPathTypeFailure, None)),
|
_ => {
|
||||||
|
debug!("Matched Index->NON-Array");
|
||||||
|
return Err(StoreError::new(StoreErrorKind::HeaderPathTypeFailure, None));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -828,6 +841,8 @@ impl Entry {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
extern crate env_logger;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use super::EntryHeader;
|
use super::EntryHeader;
|
||||||
use super::Token;
|
use super::Token;
|
||||||
|
|
Loading…
Reference in a new issue