Skip to content

fix(server): flaky metadata tests#26964

Merged
danieldietzler merged 1 commit intomainfrom
uhthomas/fix-server-flaky-metadata-tests
Mar 17, 2026
Merged

fix(server): flaky metadata tests#26964
danieldietzler merged 1 commit intomainfrom
uhthomas/fix-server-flaky-metadata-tests

Conversation

@uhthomas
Copy link
Copy Markdown
Collaborator

Description

Dates on the asset factory use the current time, and they are usually all the same time, but may occasionally be a millisecond out. This behaviour hid the fact that some tests were asserting against the wrong field, and would flake.

We can resolve this by ensuring that each date on a test asset is unique.

How Has This Been Tested?

Ran the tests.

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

N/A

Dates on the asset factory use the current time, and they are usually
all the same time, but may occasionally be a millisecond out. This
behaviour hid the fact that some tests were asserting against the wrong
field, and would flake.

We can resolve this by ensuring that each date on a test asset is
unique.
Copy link
Copy Markdown
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we'd want some sort of randomization in the newDate instead. I suppose this is fine though

Comment thread server/test/factories/asset.factory.ts
@uhthomas
Copy link
Copy Markdown
Collaborator Author

Maybe, though it might be weird to have an updated at before a created at, so this ordering kinda makes sense?

@danieldietzler danieldietzler merged commit 34caed3 into main Mar 17, 2026
65 checks passed
@danieldietzler danieldietzler deleted the uhthomas/fix-server-flaky-metadata-tests branch March 17, 2026 17:06
brucethomax pushed a commit to brucethomax/immich that referenced this pull request Mar 19, 2026
okxint pushed a commit to okxint/immich that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants