repository: Fix slow tests exceeding lockfile cleanup grace period
When cleaning up lockfiles, we have a grace period of 15 minutes before we remove them. This is done such that we don't remove any that have just been created by Git.
Now some tests in the Repository service test this by creating their own
lockfiles. They do that by using a global freshTime
variable that is
getting initialized with time.Now()
. This means that "fresh" is
whatever had been fresh when the test executable started, where on macOS
there can be a delay of more than 15 minutes until we finally execute
these tests. The result is that "fresh" is "stale" and thus tests are
flaky.
Fix this by instantiating times locally in the testcases.
Edited by Patrick Steinhardt