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

docs(contributing): add note that postgres tests require UTC #1550

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kenstir
Copy link
Contributor

@kenstir kenstir commented May 11, 2024

The tests fail if the host is not configured for UTC. A note in the CONTRIBUTING doc would have saved me hours debugging the failed test.

$ sudo timedatectl set-timezone America/New_York
$ go clean -testcache
$ go test ./internal/database -tags=integration
...
--- FAIL: TestFilterRepo_GetDownloadsByFilterId (0.03s)
    --- FAIL: TestFilterRepo_GetDownloadsByFilterId/GetDownloadsByFilterId_Succeeds_[postgres] (0.02s)
        filter_test.go:817:
                Error Trace:    /home/kenstir/opensource/autobrr/internal/database/filter_test.go:817
                Error:          Not equal:
                                expected: &domain.FilterDownloads{HourCount:0, DayCount:0, WeekCount:1, MonthCount:1, TotalCount:1}
                                actual  : &domain.FilterDownloads{HourCount:1, DayCount:1, WeekCount:1, MonthCount:1, TotalCount:1}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,4 +1,4 @@
                                 (*domain.FilterDownloads)({
                                - HourCount: (int) 0,
                                - DayCount: (int) 0,
                                + HourCount: (int) 1,
                                + DayCount: (int) 1,
                                  WeekCount: (int) 1,
                Test:           TestFilterRepo_GetDownloadsByFilterId/GetDownloadsByFilterId_Succeeds_[postgres]
FAIL
FAIL    github.com/autobrr/autobrr/internal/database    1.513s

If you change to UTC, they pass:

$ sudo timedatectl set-timezone Etc/UTC
$ go clean -testcache
$ go test ./internal/database -tags=integration
ok      github.com/autobrr/autobrr/internal/database    1.505s

@s0up4200
Copy link
Collaborator

Hm, weird. Works in macOS using CEST.

@kenstir
Copy link
Contributor Author

kenstir commented May 11, 2024

Well now that is weird that it works for you in CEST. I tracked it down to this INSERT, and just presumed that the caller was using local time. The postgres container logged an insert at 2024-05-11T00:16:28 but param $9 to the insert was 2024-05-10 20:16:28 (local time):

autobrr_postgres_test  | 2024-05-11T00:16:28.517315851Z 2024-05-11 00:16:28.517 UTC [34] LOG:  execute <unnamed>: INSERT INTO release_action_status (status,action,action_id,type,client,filter,filter_id,rejections,timestamp,release_id) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10) RETURNING id
autobrr_postgres_test  | 2024-05-11T00:16:28.517332177Z 2024-05-11 00:16:28.517 UTC [34] DETAIL:  parameters: $1 = 'PUSH_APPROVED', $2 = 'okay', $3 = '11', $4 = 'TEST', $5 = 'qbitorrent', $6 = 'Test filter', $7 = '50', $8 = '{"one rejection","two rejections"}', $9 = '2024-05-10 20:16:28', $10 = '1'

@zze0s zze0s added the documentation Improvements or additions to documentation label May 15, 2024
@zze0s zze0s added this to the v1.43.0 milestone May 15, 2024
@zze0s zze0s changed the title docs: add note that postgres tests require UTC docs(contributing): add note that postgres tests require UTC May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

None yet

3 participants