test: add unit tests for previously uncovered server components#6301
Open
test: add unit tests for previously uncovered server components#6301
Conversation
…configured_vcs_client Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add unit tests for missing coverage areas
Add unit tests for ClientProxy, AutoMerger, PullReqStatusFetcher, and NotConfiguredVCSClient
Mar 10, 2026
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Copilot
AI
changed the title
Add unit tests for ClientProxy, AutoMerger, PullReqStatusFetcher, and NotConfiguredVCSClient
test: add unit tests for previously uncovered server components
Mar 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds focused unit/internal tests around VCS client wrappers/proxies and a couple of unexported events helpers to improve confidence in routing, error propagation, and filtering behavior.
Changes:
- Add unit tests for
vcs.PullReqStatusFetchercovering success, error paths, and argument passing. - Add unit tests for
vcs.ClientProxy,vcs.NotConfiguredVCSClient, andcommon.InstrumentedClientbehavior/error propagation. - Add internal-package tests for
events.AutoMergerandevents.DBUpdater.updateDB(filteringDirNotExistErrresults).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| server/events/vcs/pull_status_fetcher_test.go | Tests PR approval/mergeability status fetching, including error wrapping and arg forwarding. |
| server/events/vcs/proxy_test.go | Tests ClientProxy dispatching to the correct underlying VCS client and error propagation. |
| server/events/vcs/not_configured_vcs_client_test.go | Tests placeholder client error/no-op behaviors and error message host identification. |
| server/events/vcs/common/instrumented_client_test.go | Tests InstrumentedClient passthrough behavior and special-case no-op for UpdateStatus when pull.Num==0. |
| server/events/db_updater_internal_test.go | Internal tests for updateDB filtering of DirNotExistErr before DB update calls. |
| server/events/automerger_internal_test.go | Internal tests for AutoMerger merge/comment behavior and enablement helper logic. |
| ) | ||
| } | ||
|
|
||
| func TestAutomerge_EmptyProjects_DoesNotMerge(t *testing.T) { |
Comment on lines
+145
to
+148
| // PullStatus with no projects – nothing to check, nothing to merge. | ||
| am.automerge(ctx, models.PullStatus{}, false, "") | ||
|
|
||
| // No projects == vacuously all applied → should still merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Six critical server components had zero test coverage. This adds focused unit tests for each, covering success paths, error propagation, and edge cases.
New test files
server/events/vcs/proxy_test.go—ClientProxyrouting: nil slots becomeNotConfiguredVCSClient; all 15 interface methods dispatch to the correct client for each of the 6 VCS host types; errors propagate unchanged.server/events/vcs/pull_status_fetcher_test.go—FetchPullStatus: success path, approval/mergeable API failures wrapped with repo+PR context,vcsStatusNameandignoreVCSStatusNamesforwarded correctly.server/events/vcs/not_configured_vcs_client_test.go— Error-producing methods return errors containing the host name across all 6 host types; no-op methods (HidePrevCommandComments,ReactToComment,DiscardReviews) return nil.server/events/automerger_internal_test.go—automerge: only fires when all projects areAppliedPlanStatus; merge failure posts a second comment;DeleteSourceBranchOnMerge/MergeMethodpass through.automergeEnabled: project-level settings override global flag.server/events/vcs/common/instrumented_client_test.go— All 7 wrapped VCS methods covered for success and error paths. Key edge case:UpdateStatuswithpull.Num == 0must skip the underlying call entirely (guards against updating status on non-PR plans).server/events/db_updater_internal_test.go—DirNotExistErrresults are filtered before forwarding to the DB; non-DirNotExistErrerrors are kept; empty/all-filtered inputs produce a nil slice; DB errors propagate.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
custom.domain/tmp/go-build2557932835/b790/gitlab.test /tmp/go-build2557932835/b790/gitlab.test -test.testlogfile=/tmp/go-build2557932835/b790/testlog.txt -test.paniconexit0 -test.timeout=10m0s -o WORKSPACE=$WORKSPACE ATLANTIS_TERRAFORM_VERSION=$ATLANTIS_TERRAFORM_VERSION DIR/tmp/go-build2557932835/b779/importcfg t ux-amd64/pkg/tool/linux_amd64/vet -p ng1177848672/001-test.testlogfile=/tmp/go-build2557932835/b715/testlog.txt 48672/002/repos/-test.paniconexit0 ux-amd64/pkg/too-test.timeout=10m0s -uns�� 20200823014737-9f7001d12a5f/rdv.go t 0.1-go1.25.4.linux-amd64/pkg/tool/linux_amd64/compile -c=4 -nolocalimports t 0.1-go1.25.4.linux-amd64/pkg/too-trimpath(dns block)get.opentofu.org/tmp/go-build2557932835/b731/terraform.test /tmp/go-build2557932835/b731/terraform.test -test.testlogfile=/tmp/go-build2557932835/b731/testlog.txt -test.paniconexit0 -test.timeout=10m0s(dns block)/tmp/go-build3624811560/b001/terraform.test /tmp/go-build3624811560/b001/terraform.test -test.testlogfile=/tmp/go-build3624811560/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -c=4 -nolocalimports -importcfg /tmp/go-build2557932835/b796/importcfg -pack /home/REDACTED/work/atlantis/atlantis/server/events/webhooks/mocks/mock_sender.go /home/REDACTED/work/atlantis/atlantis/server/events/webhooks/mocks/mock_slack_client.go -uns�� lowFullClone260267613/001/repos/-p t ux-amd64/pkg/tool/linux_amd64/vet t/decode.go t/decode_number.-test.testlogfile=/tmp/go-build2557932835/b785/testlog.txt t ux-amd64/pkg/too-test.timeout=10m0s(dns block)/tmp/go-build2384682044/b001/terraform.test /tmp/go-build2384682044/b001/terraform.test -test.testlogfile=/tmp/go-build2384682044/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=TestResolveOpenTofuVersions|TestOpenTofuInstall -test.v=true t ux-amd64/pkg/tool/linux_amd64/compile -errorsas -ifaceassert t ux-amd64/pkg/tool/linux_amd64/compile -uns�� 1194616/b568/_pkg_.a t ux-amd64/pkg/tool/linux_amd64/vet g_.a ux-amd64/src/os/-u l/linux_amd64/vebin/WALinuxAgent-2.15.1.3-py3.12.egg ux-amd64/pkg/too-collect-logs(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.