Skip to content

Commit

Permalink
fix testcases while chrono-tz enabled (#2932)
Browse files Browse the repository at this point in the history
* fix testcases

* add arrow test with all features

* add chrono-tz in features

* remove chrono-tz

* remove duplicated blocks
  • Loading branch information
waitingkuo committed Oct 26, 2022
1 parent f812d2c commit ed5843e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/arrow.yml
Expand Up @@ -68,9 +68,9 @@ jobs:
run: cargo test -p arrow-integration-test --all-features
- name: Test arrow
run: cargo test -p arrow
- name: Test --features=force_validate,prettyprint,ipc_compression,ffi,dyn_cmp_dict,dyn_arith_dict
- name: Test --features=force_validate,prettyprint,ipc_compression,ffi,dyn_cmp_dict,dyn_arith_dict,chrono-tz
run: |
cargo test -p arrow --features=force_validate,prettyprint,ipc_compression,ffi,dyn_cmp_dict,dyn_arith_dict
cargo test -p arrow --features=force_validate,prettyprint,ipc_compression,ffi,dyn_cmp_dict,dyn_arith_dict,chrono-tz
- name: Run examples
run: |
# Test arrow examples
Expand Down
8 changes: 4 additions & 4 deletions arrow/src/compute/kernels/cast.rs
Expand Up @@ -3853,8 +3853,8 @@ mod tests {
let b = cast(&array, &DataType::Utf8).unwrap();
let c = b.as_any().downcast_ref::<StringArray>().unwrap();
assert_eq!(&DataType::Utf8, c.data_type());
assert_eq!("1997-05-19 00:00:00.005", c.value(0));
assert_eq!("2018-12-25 00:00:00.001", c.value(1));
assert_eq!("1997-05-19 00:00:00.005 +00:00", c.value(0));
assert_eq!("2018-12-25 00:00:00.001 +00:00", c.value(1));
assert!(c.is_null(2));
}

Expand Down Expand Up @@ -5754,9 +5754,9 @@ mod tests {
let out = cast(&(Arc::new(array) as ArrayRef), &DataType::Utf8).unwrap();

let expected = StringArray::from(vec![
Some("1970-01-01 20:30:00"),
Some("1970-01-01 20:30:00 +10:00"),
None,
Some("1970-01-02 09:58:59"),
Some("1970-01-02 09:58:59 +10:00"),
]);

assert_eq!(
Expand Down
19 changes: 4 additions & 15 deletions arrow/src/csv/writer.rs
Expand Up @@ -524,25 +524,14 @@ mod tests {
let mut buffer: Vec<u8> = vec![];
file.read_to_end(&mut buffer).unwrap();

let expected = if cfg!(feature = "chrono-tz") {
r#"c1,c2,c3,c4,c5,c6,c7
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378000000+00:00,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000+00:00,23:46:03,foo
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378000000+00:00,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000+00:00,23:46:03,foo
"#
} else {
r#"c1,c2,c3,c4,c5,c6,c7
let expected = r#"c1,c2,c3,c4,c5,c6,c7
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378000000,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
Lorem ipsum dolor sit amet,123.564532,3,true,,00:20:34,cupcakes
consectetur adipiscing elit,,2,false,2019-04-18T10:54:47.378000000,06:51:20,cupcakes
sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
"#
};
"#;
assert_eq!(expected.to_string(), String::from_utf8(buffer).unwrap());
}

Expand Down Expand Up @@ -646,8 +635,8 @@ sed do eiusmod tempor,-556132.25,1,,2019-04-18T02:45:55.555000000,23:46:03,foo
}

let left = "c1,c2
2019-04-18T20:54:47.378000000+10:00,2019-04-18T10:54:47.378000000+00:00
2021-10-30T17:59:07.000000000+11:00,2021-10-30T06:59:07.000000000+00:00\n";
2019-04-18T20:54:47.378000000+10:00,2019-04-18T10:54:47.378000000
2021-10-30T17:59:07.000000000+11:00,2021-10-30T06:59:07.000000000\n";
let right = writer.writer.into_inner().map(|s| s.to_string());
assert_eq!(Some(left.to_string()), right.ok());
}
Expand Down

0 comments on commit ed5843e

Please sign in to comment.