Command tests (#922)

* WIP command tests

* Finish marking todo tests

* update

* update

* Windows cd test ignoring
This commit is contained in:
JT
2022-02-03 21:01:45 -05:00
committed by GitHub
parent ac0b331f00
commit a008f1aa80
139 changed files with 10298 additions and 348 deletions

View File

@ -94,6 +94,13 @@ END:VCALENDAR' | from ics",
fn from_ics(input: PipelineData, head: Span, config: &Config) -> Result<PipelineData, ShellError> {
let input_string = input.collect_string("", config)?;
let input_string = input_string
.lines()
.map(|x| x.trim().to_string())
.collect::<Vec<_>>()
.join("\n");
let input_bytes = input_string.as_bytes();
let buf_reader = BufReader::new(input_bytes);
let parser = ical::IcalParser::new(buf_reader);
@ -103,9 +110,9 @@ fn from_ics(input: PipelineData, head: Span, config: &Config) -> Result<Pipeline
for calendar in parser {
match calendar {
Ok(c) => output.push(calendar_to_value(c, head)),
Err(_) => output.push(Value::Error {
Err(e) => output.push(Value::Error {
error: ShellError::UnsupportedInput(
"input cannot be parsed as .ics".to_string(),
format!("input cannot be parsed as .ics ({})", e),
head,
),
}),

View File

@ -125,14 +125,24 @@ END:VCARD' | from vcf",
fn from_vcf(input: PipelineData, head: Span, config: &Config) -> Result<PipelineData, ShellError> {
let input_string = input.collect_string("", config)?;
let input_string = input_string
.lines()
.map(|x| x.trim().to_string())
.collect::<Vec<_>>()
.join("\n");
let input_bytes = input_string.as_bytes();
let cursor = std::io::Cursor::new(input_bytes);
let parser = ical::VcardParser::new(cursor);
let iter = parser.map(move |contact| match contact {
Ok(c) => contact_to_value(c, head),
Err(_) => Value::Error {
error: ShellError::UnsupportedInput("input cannot be parsed as .vcf".to_string(), head),
Err(e) => Value::Error {
error: ShellError::UnsupportedInput(
format!("input cannot be parsed as .vcf ({})", e),
head,
),
},
});