Skip to content

test: add unit tests for previously uncovered server components#6301

Open
Copilot wants to merge 3 commits intomainfrom
copilot/enhance-unit-test-coverage
Open

test: add unit tests for previously uncovered server components#6301
Copilot wants to merge 3 commits intomainfrom
copilot/enhance-unit-test-coverage

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

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.goClientProxy routing: nil slots become NotConfiguredVCSClient; 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.goFetchPullStatus: success path, approval/mergeable API failures wrapped with repo+PR context, vcsStatusName and ignoreVCSStatusNames forwarded 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.goautomerge: only fires when all projects are AppliedPlanStatus; merge failure posts a second comment; DeleteSourceBranchOnMerge/MergeMethod pass 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: UpdateStatus with pull.Num == 0 must skip the underlying call entirely (guards against updating status on non-PR plans).

  • server/events/db_updater_internal_test.goDirNotExistErr results are filtered before forwarding to the DB; non-DirNotExistErr errors 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
    • Triggering command: /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
    • Triggering command: /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)
    • Triggering command: /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)
    • Triggering command: /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.

…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
@nitrocode nitrocode marked this pull request as ready for review March 15, 2026 05:29
Copilot AI review requested due to automatic review settings March 15, 2026 05:29
@dosubot dosubot bot added the go Pull requests that update Go code label Mar 15, 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

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.PullReqStatusFetcher covering success, error paths, and argument passing.
  • Add unit tests for vcs.ClientProxy, vcs.NotConfiguredVCSClient, and common.InstrumentedClient behavior/error propagation.
  • Add internal-package tests for events.AutoMerger and events.DBUpdater.updateDB (filtering DirNotExistErr results).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code size/l size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants