Repository navigation
fix(parser): stop the .msg date test depending on the host timezone - #19182
Conversation
TestEmailParser_MsgSupported asserted the literal string "2018-03-24 00:06:29+0800". That value only holds on a host at +0800. formatMsgDate renders msg.Date with the "-0700" layout. gomsg builds that time in filetimeToTime with time.Unix, which returns a Time in the local location. The rendered offset therefore follows TZ. Measured on 4168b3f, with TZ set for one run each: Asia/Shanghai ok America/New_York got "2018-03-23 12:06:29-0400" UTC got "2018-03-23 16:06:29+0000" Europe/Berlin got "2018-03-23 17:06:29+0100" Parse the value with the same layout and compare the instant. That keeps both properties the old assertion checked, the layout and the time, and drops the host dependency. The parser is unchanged. Signed-off-by: Yash Raj Pandey <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe MSG date test now parses the rendered date and compares the result with the expected UTC instant. This removes dependence on the host timezone. ChangesTimezone-independent test validation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This change makes the existing date test independent of the host timezone without altering production behavior. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
TestEmailParser_MsgSupportedasserts the literal string2018-03-24 00:06:29+0800. The test only passes on a host at +0800.formatMsgDaterendersmsg.Datewith the-0700layout.gomsgbuilds that time infiletimeToTimewithtime.Unix, which returns atime.Timein the local location. The rendered offset followsTZ, so the correct expected string does too.Measured on
4168b3f9d, one run per zone:Asia/ShanghaiAmerica/New_York"2018-03-23 12:06:29-0400"UTC"2018-03-23 16:06:29+0000"Europe/Berlin"2018-03-23 17:06:29+0100"All four strings are the same instant.
docker/.envline 291 setsTZ=Asia/Shanghai, so CI stays green. A contributor in another zone gets a red package on a clean checkout.The parser is correct, so this PR does not touch it. The test now parses the value with the same layout and compares the instant.
The new assertion passes under
Asia/Shanghai,America/New_York,UTC,Europe/Berlin,Australia/Sydney,Asia/KolkataandPacific/Kiritimati.It still catches a broken
formatMsgDate. I applied each mutation to the parser and ran the test underAmerica/New_York:-07:00instead of-0700cannot parse "-04:00" as "-0700"t.Add(time.Hour)before the formatgot "2018-03-23 13:06:29-0400" = 2018-03-23 17:06:29 +0000 UTC, want 2018-03-23 16:06:29 +0000 UTCcannot parse "" as "-0700"