Unit tests are timezone-dependent #104219

Closed
opened 2023-05-31 21:30:15 +02:00 by Sybren A. Stüvel · 0 comments

System Information
Operating System(s): Linux

Flamenco Version
Is Broken: current main branch
Worked OK: likely never

Short description of error
go test ./... fails with various date/time-related errors unless the computer's timezone is configured as Europe/Amsterdam.

Workaround for people facing this issue: run with env TZ=Europe/Amsterdam go test ./...

Exact steps for others to reproduce the error

Run this:

```env TZ=UTC+9 go test ./...`

and see various tests go wrong. Some examples:

--- FAIL: TestSimpleBlenderRenderOutputPathFieldReplacement (0.00s)
    job_compilers_test.go:253:
                Error Trace:    job_compilers_test.go:253
                Error:          Not equal:
                                expected: "/root/2006-01-02_090405/jobname/######"
                                actual  : "/root/2006-01-02_080405/jobname/######"

--- FAIL: TestCalculateNextCheck (0.00s)
    calculations_test.go:26:
                Error Trace:    calculations_test.go:26
                Error:          Not equal:
                                expected: time.Date(2022, time.June, 7, 18, 0, 0, 0, time.Location(""))
                                actual  : time.Date(2022, time.June, 7, 18, 0, 0, 0, time.Local)
    calculations_test.go:42:
                Error Trace:    calculations_test.go:42
                Error:          Not equal:
                                expected: time.Date(2022, time.June, 8, 0, 0, 0, 0, time.UTC)
                                actual  : time.Date(2022, time.June, 7, 9, 0, 0, 0, time.Local)

--- FAIL: TestSetScheduleSwappedStartEnd (0.00s)
    sleep_scheduler.go:79: Unexpected call to *mocks.MockPersistenceService.SetWorkerSleepSchedule([context.Background aeb49d8a-6903-41b3-b545-77b7a1c0ca19 0xc00035cb40]) at /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler.go:79 because:
        expected call at /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler_test.go:92 doesn't match the argument at index 2.
        Got: &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0000 UTC} (*persistence.SleepSchedule)
        Want: is equal to &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0200 +0200} (*persistence.SleepSchedule)
    controller.go:137: missing call(s) to *mocks.MockPersistenceService.SetWorkerSleepSchedule(is equal to context.Background (*context.emptyCtx), is equal to aeb49d8a-6903-41b3-b545-77b7a1c0ca19 (string), is equal to &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0200 +0200} (*persistence.SleepSchedule)) /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler_test.go:92
    controller.go:137: aborting test due to missing call(s)
**System Information** Operating System(s): Linux **Flamenco Version** Is Broken: current `main` branch Worked OK: likely never **Short description of error** `go test ./...` fails with various date/time-related errors unless the computer's timezone is configured as Europe/Amsterdam. **Workaround** for people facing this issue: run with `env TZ=Europe/Amsterdam go test ./...` **Exact steps for others to reproduce the error** Run this: ```env TZ=UTC+9 go test ./...` and see various tests go wrong. Some examples: ``` --- FAIL: TestSimpleBlenderRenderOutputPathFieldReplacement (0.00s) job_compilers_test.go:253: Error Trace: job_compilers_test.go:253 Error: Not equal: expected: "/root/2006-01-02_090405/jobname/######" actual : "/root/2006-01-02_080405/jobname/######" --- FAIL: TestCalculateNextCheck (0.00s) calculations_test.go:26: Error Trace: calculations_test.go:26 Error: Not equal: expected: time.Date(2022, time.June, 7, 18, 0, 0, 0, time.Location("")) actual : time.Date(2022, time.June, 7, 18, 0, 0, 0, time.Local) calculations_test.go:42: Error Trace: calculations_test.go:42 Error: Not equal: expected: time.Date(2022, time.June, 8, 0, 0, 0, 0, time.UTC) actual : time.Date(2022, time.June, 7, 9, 0, 0, 0, time.Local) --- FAIL: TestSetScheduleSwappedStartEnd (0.00s) sleep_scheduler.go:79: Unexpected call to *mocks.MockPersistenceService.SetWorkerSleepSchedule([context.Background aeb49d8a-6903-41b3-b545-77b7a1c0ca19 0xc00035cb40]) at /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler.go:79 because: expected call at /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler_test.go:92 doesn't match the argument at index 2. Got: &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0000 UTC} (*persistence.SleepSchedule) Want: is equal to &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0200 +0200} (*persistence.SleepSchedule) controller.go:137: missing call(s) to *mocks.MockPersistenceService.SetWorkerSleepSchedule(is equal to context.Background (*context.emptyCtx), is equal to aeb49d8a-6903-41b3-b545-77b7a1c0ca19 (string), is equal to &{{0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} 0 0xc000161d40 true mo tu we 09:00 18:00 2022-06-07 18:00:00 +0200 +0200} (*persistence.SleepSchedule)) /home/sybren/workspace/flamenco/internal/manager/sleep_scheduler/sleep_scheduler_test.go:92 controller.go:137: aborting test due to missing call(s) ```
Sybren A. Stüvel added the
Type
Bug
label 2023-05-31 21:30:32 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: studio/flamenco#104219
No description provided.