Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixed timezone for tests #319

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

milankonir
Copy link
Contributor

The tests are failing when ran in a TZ different from GMT.

--- FAIL: TestEncodePartDefaultHeaders (0.00s)
    encode_test.go:71: Test output did not match testdata/encode/part-default-headers.golden
        To update golden file, run: go test -update
    encode_test.go:71: diff -want +got:
        | Content-Disposition: attachment; filename=stuff.zip; modification-date="01
        |- Feb 03 04:05 GMT"
        |+ Feb 03 05:05 CET"
        | Content-Id: <mycontentid>
        | Content-Transfer-Encoding: base64
        ...
        | WklQWklQWklQ
        | 

This PR fixates test run to TZ=Europe/London

@coveralls
Copy link

coveralls commented Jan 7, 2024

Coverage Status

coverage: 86.283%. remained the same
when pulling df13d57 on milankonir:fix-timezone-for-tests
into 61b3eaf on jhillyerd:main.

@jhillyerd
Copy link
Owner

For the record, I am not in GMT/UTC, and am unable to duplicate the failure with any of:

env TZ=CET go test -race -count 1 ./...
env TZ=America/Los_Angeles go test -race -count 1 ./...
env TZ=Europe/London go test -race -count 1 ./...

Perhaps this is a change in a newer version of Go than the 1.20.11 I am running. Either way, I don't think altering the Makefile is the correct way to fix this, as IDEs and GitHub CI won't be using Makefiles.

Someone contributed a similar fix to one of my other projects in https://github.com/inbucket/inbucket/pull/406/files -- that's likely to be a better approach, if we can use it here.

@milankonir
Copy link
Contributor Author

milankonir commented Jan 11, 2024

Interesting, figured out the test were failing for my TZ specifically. You can reproduce yourself by running:

TZ=Europe/Prague go test -race ./... 

I assume it has to do with zone abbreviation vs current locale behavior described in https://pkg.go.dev/time#Parse

Originally, I did not want to make code changes for the sake of tests, but formatting the mod date in UTC should not do any harm.

@jhillyerd
Copy link
Owner

Ah, yes, your example does fail for me, interesting.

Thanks for sending in the fix.

@jhillyerd jhillyerd merged commit c47e440 into jhillyerd:main Jan 11, 2024
9 checks passed
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.

None yet

3 participants