Skip to content

fix: Update mocks for change to working dir locker interface#6248

Open
lukemassa wants to merge 2 commits intorunatlantis:mainfrom
lukemassa:update_mocks_for_working_dir_locker
Open

fix: Update mocks for change to working dir locker interface#6248
lukemassa wants to merge 2 commits intorunatlantis:mainfrom
lukemassa:update_mocks_for_working_dir_locker

Conversation

@lukemassa
Copy link
Contributor

what

Update mocks for change to working dir locker interface

why

#6086 changed the interface of TryLock, and it does appear that new mocks were generated, but somehow not all the mock was updated (maybe an older version of pegomock?)

Either way, I noticed this when running pegomock for an unrelated reason, and saw that the verify code in a unit test had the wrong number of args.

tests

Ran unit tests

references

Bug introduced in: #6086

Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
Copilot AI review requested due to automatic review settings February 22, 2026 21:40
@dosubot
Copy link

dosubot bot commented Feb 22, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added bug Something isn't working go Pull requests that update Go code labels Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the pegomock-generated WorkingDirLocker mock and a couple of unit-test verifications to match the TryLock(..., projectName, ...) interface change introduced in #6086, ensuring tests/mocks compile and verify calls use the correct arity.

Changes:

  • Update VerifyWasCalled(...).TryLock(...) usages in pre/post workflow hook runner tests to include the new projectName argument.
  • Regenerate/update MockWorkingDirLocker verifier/captured-args helpers to match the new TryLock signature.
  • Align captured argument extraction in the mock to include projectName as a string parameter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
server/events/pre_workflow_hooks_command_runner_test.go Updates TryLock verification to include projectName argument.
server/events/post_workflow_hooks_command_runner_test.go Updates TryLock verification to include projectName argument.
server/events/mocks/mock_working_dir_locker.go Updates pegomock-generated mock/verifier to the new TryLock signature and captured args.

whPreWorkflowHookRunner.VerifyWasCalled(Never()).Run(Any[models.WorkflowHookCommandContext](), Eq(testHook.RunCommand),
Eq(defaultShell), Eq(defaultShellArgs), Eq(repoDir))
preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "", command.Plan)
preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "", "", command.Plan)
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

This VerifyWasCalled(Never()).TryLock(...) uses concrete argument values, so it only verifies that TryLock was never called with this exact parameter set. If TryLock were called with different path/projectName values, this test would still pass. Consider using Any[...]() matchers for all parameters (or another pegomock pattern) to assert TryLock is never called at all in this branch.

Suggested change
preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "", "", command.Plan)
preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(
Any[string](),
Any[int](),
Any[string](),
Any[string](),
Any[string](),
Any[command.Name](),
)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot interesting point, but do we want to assert this was never called? Presumably we want some of these args to be concrete, and others Any?

whPostWorkflowHookRunner.VerifyWasCalled(Never()).Run(Any[models.WorkflowHookCommandContext](),
Eq(testHook.RunCommand), Eq(defaultShell), Eq(defaultShellArgs), Eq(repoDir))
postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "path", command.Plan)
postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "path", "", command.Plan)
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

This VerifyWasCalled(Never()).TryLock(...) uses concrete argument values, so it only verifies that TryLock was never called with this exact parameter set. If TryLock were called with different path/projectName values, this test would still pass. Consider using Any[...]() matchers for all parameters (or another pegomock pattern) to assert TryLock is never called at all in this branch.

Suggested change
postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "path", "", command.Plan)
postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(Any[string](), Any[int](), Any[string](), Any[string](), Any[string](), Any[command.Name]())

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants