Skip to content

chore: fixed broken test (timezones 🤷) - #187

Open
fearphage wants to merge 1 commit into
backstage:mainfrom
fearphage:cron/fix-test
Open

chore: fixed broken test (timezones 🤷)#187
fearphage wants to merge 1 commit into
backstage:mainfrom
fearphage:cron/fix-test

Conversation

@fearphage

Copy link
Copy Markdown

This test fails consistently locally. There seems to be a logic issue with respect to time zones.

Details

The test expects to run on midnight Tuesday UTC (2022-06-28) using a fake timer. However it was actually generating a date that was relative to the local time. So for me, midnight UTC is 7pm CDT on the previous day (06-27 which is a Monday) so the test would fail. I patched this by always adjusting the time based on the timezone offset.

Verification

From a very basic set of local testing, it seems to pass consistently (where the main branch fails):

➜  backstage-actions git:(cron/fix-test) for x in America/Los_Angeles America/New_York Etc/GMT Africa/Nairobi Asia/Tokyo Pacific/Kiritimati; do if env TZ="$x" yarn test cron/mergeRenovatePRs.test.ts &> /dev/null; then outcome='passed'; else outcome='FAILED'; fi; printf '%-20s -> %s\n' "$x" "$outcome"; done
America/Los_Angeles  -> passed
America/New_York     -> passed
Etc/GMT              -> passed
Africa/Nairobi       -> passed
Asia/Tokyo           -> passed
Pacific/Kiritimati   -> passed
➜  backstage-actions git:(cron/fix-test) gcm
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
➜  backstage-actions git:(main) for x in America/Los_Angeles America/New_York Etc/GMT Africa/Nairobi Asia/Tokyo Pacific/Kiritimati; do if env TZ="$x" yarn test cron/mergeRenovatePRs.test.ts &> /dev/null; then outcome='passed'; else outcome='FAILED'; fi; printf '%-20s -> %s\n' "$x" "$outcome"; done
America/Los_Angeles  -> FAILED
America/New_York     -> FAILED
Etc/GMT              -> passed
Africa/Nairobi       -> passed
Asia/Tokyo           -> passed
Pacific/Kiritimati   -> passed

Signed-off-by: Phred <fearphage@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant