liquid-rust icon indicating copy to clipboard operation
liquid-rust copied to clipboard

`test_date` is failing for unknown reasons

Open epage opened this issue 6 years ago • 3 comments

Example test

    assert_eq!(
        v!("May"),
        filters!(date, with_time("2006-05-05 10:00:00"), v!("%B"))
    );

epage avatar Nov 30 '18 23:11 epage

Looking into this further (even though I've been away from the code for about 4-5 years), it looks like this should be expected. In the two places defined, the function with_time returns Nil:

https://github.com/cobalt-org/liquid-rust/blob/1a6631d0ce69a4c7c72bf11f7284c853b775a3f1/tests/test_helper.rs#L10-L13

and

https://github.com/cobalt-org/liquid-rust/blob/1a6631d0ce69a4c7c72bf11f7284c853b775a3f1/crates/lib/tests/test_helper.rs#L10-L13

There are a number of issues in the test_date function. I'm going to break them out into separate test functions to make it easier to see which are failing and which aren't.

For this particular issue, even if you remove the with_time function call and only pass the date/time string ("2006-05-05 10:00:00"), the format by which it is trying to interpret the string, v!("%B"), is not valid for the string to be parsed.

I think the following would be a better way to test the month name functionality, but please cross-check me:

    assert_eq!(
        v!("May"),
        call_filter!(liquid_lib::stdlib::Date, "May", v!("%B")).unwrap()
    );

If the intent is something else, please let me know.

djwf avatar Mar 29 '22 23:03 djwf

Looking into this further (even though I've been away from the code for about 4-5 years), it looks like this should be expected. In the two places defined, the function with_time returns Nil:

Can't believe I missed that with_time is not implemented. That needs fixing

There are a number of issues in the test_date function. I'm going to break them out into separate test functions to make it easier to see which are failing and which aren't.

Any test in conformance_ruby should not be cleaned up; they are a direct port from Shopify's liquid and we want them to line up for easier updating. For example, see their test_date: https://github.com/Shopify/liquid/blob/master/test/integration/standard_filter_test.rb#L530

epage avatar Mar 30 '22 02:03 epage

Got it - I'll leave the tests be, and work on implementing with_time. :)

djwf avatar Mar 30 '22 02:03 djwf