Phase 3: Test coverage improvement -- cmd, project, azapi, pipeline, grpcserver (42.8% -> 58.0%)#7496
Phase 3: Test coverage improvement -- cmd, project, azapi, pipeline, grpcserver (42.8% -> 58.0%)#7496
Conversation
Add 16 test files covering cmd constructors, flag parsing, Run() error paths, utility functions, and action methods (env*, config*, update, template, container, copilot, extensions). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 36 test files covering project config parsing, service resolution, framework services (Docker, SWA, custom, noop), service targets (App Service, Container App, DotNet Container App), scaffold generation, importer, infrastructure spec, container helpers, and service manager lifecycle methods (Package, Deploy, Publish, Build). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 6 test files covering ResourceService operations, StandardDeployments (deploy, what-if, validate, provisioning states), Azure client services (APIM, AppConfig, LogAnalytics, ManagedHSM, WebApp), ManagedClusters, CognitiveService (AI models, usages, SKU locations), and all 42 resource type display name mappings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add pipeline_coverage3_test.go covering GitHub CI/SCM providers, Azure DevOps CI/SCM providers, pipeline manager operations (configure, push, determineProvider, promptForProvider), mergeProjectVariablesAndSecrets (all 6 parameter branches), generateFilePaths, generatePipelineDefinition, and hasPipelineFile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 15 test files covering gRPC service handlers: prompt service (helpers, interactive, AI prompts), copilot service, environment service, project service, container/compose/deployment services, user config, AI model service, extension claims, workflow validation, account service, framework constructors, and server lifecycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR (“Phase 3”) significantly increases unit test coverage across major packages (cmd, pkg/project, pkg/azapi, pkg/pipeline, internal/grpcserver) and raises the coverage gate accordingly.
Changes:
- Adds a large suite of new
_coverage3_test.gofiles to cover previously untested branches and error paths. - Introduces additional unit tests for YAML marshal/unmarshal, packaging/zip creation, resource services, and gRPC server services validation/error mapping.
- Adds constructor and utility “smoke tests” to cover initialization code paths.
Reviewed changes
Copilot reviewed 58 out of 75 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/project/resources_coverage3_test.go | Adds tests for resource type lists and YAML marshal/unmarshal for ResourceConfig and typed props. |
| cli/azd/pkg/project/project_utils_coverage3_test.go | Adds tests for .NET docker publish decision logic and basic zip creation scenarios. |
| cli/azd/pkg/project/project_utils3_coverage3_test.go | Adds zip creation tests covering ignore files and directory exclusions, plus zip inspection helper. |
| cli/azd/pkg/project/project_utils2_coverage3_test.go | Adds additional zip creation branching tests for various languages and ignore-file handling. |
| cli/azd/pkg/project/project_coverage3_test.go | Adds tests for config load/save/parse functions and hooks file parsing. |
| cli/azd/pkg/project/project_config_coverage3_test.go | Adds tests for service context, progress, and hooks config marshal/unmarshal round-trips. |
| cli/azd/pkg/project/mixed_coverage3_test.go | Adds tests for HasAppHost behavior and functionAppTarget.Package artifact handling. |
| cli/azd/pkg/project/mapper_registry_coverage3_test.go | Adds tests for typed resource props creation, resource kinds mapping, and proto enum conversion. |
| cli/azd/pkg/project/importer_coverage3_test.go | Adds tests for provider detection, module existence, infra cleanup, and dependency sorting/validation. |
| cli/azd/pkg/project/importer2_coverage3_test.go | Adds tests for importer helpers, service filtering, HasAppHost, language parsing, and enablement logic. |
| cli/azd/pkg/project/framework_services_coverage3_test.go | Adds tests for framework service requirement/tool/initialize behavior across runtimes. |
| cli/azd/pkg/project/framework_service_swa_coverage3_test.go | Adds tests for SWA framework service wrapper behavior and outputs. |
| cli/azd/pkg/project/framework_service_noop_coverage3_test.go | Adds tests for NoOp framework project and package output validation. |
| cli/azd/pkg/project/framework_service_docker_coverage3_test.go | Adds tests for docker framework service, tool requirements, and deployment ignore helper logic. |
| cli/azd/pkg/project/framework_service_custom_coverage3_test.go | Adds tests for custom framework service outputs and error path when dist/output missing. |
| cli/azd/pkg/project/extra_coverage3_test.go | Adds tests for infra generation error cases, container app target methods, and infra cleanup. |
| cli/azd/pkg/project/dockerfile_builder_coverage3_test.go | Adds extensive tests for dockerfile builder output formatting and stage features. |
| cli/azd/pkg/project/container_helper_coverage3_test.go | Adds tests for docker options defaulting and dockerfile builder construction. |
| cli/azd/pkg/project/constructors_coverage3_test.go | Adds constructor and small helper method coverage around project/service managers and targets. |
| cli/azd/pkg/azapi/resource_service_coverage3_test.go | Adds tests for ResourceService CRUD/list operations and grouping helpers using mock HTTP. |
| cli/azd/pkg/azapi/managed_clusters_coverage3_test.go | Adds tests for managed clusters get and credential listing with mock HTTP. |
| cli/azd/pkg/azapi/cognitive_service_coverage3_test.go | Adds tests for AI models/usages/SKU location helpers via mock HTTP. |
| cli/azd/pkg/azapi/azure_resource_types_coverage3_test.go | Adds exhaustive switch-case coverage for resource type display names. |
| cli/azd/pkg/azapi/azure_client_services_coverage3_test.go | Adds tests for several Azure client service operations (APIM, AppConfig, LogAnalytics, HSM, WebApp). |
| cli/azd/internal/grpcserver/workflow_service_coverage3_test.go | Adds validation tests for workflow run requests (nil/empty workflow, empty commands). |
| cli/azd/internal/grpcserver/user_config_service_coverage3_test.go | Adds tests for user config gRPC service operations using mock config manager. |
| cli/azd/internal/grpcserver/server_coverage3_test.go | Adds tests for server auth/token validation and error wrapping interceptors. |
| cli/azd/internal/grpcserver/framework_service_coverage3_test.go | Adds constructor smoke tests for framework and target services. |
| cli/azd/internal/grpcserver/extension_service_coverage3_test.go | Adds claims validation tests and extension token generate/parse round-trips. |
| cli/azd/internal/grpcserver/deployment_service_coverage3_test.go | Adds tests for deployment service error paths and env/default env handling. |
| cli/azd/internal/grpcserver/container_service_coverage3_test.go | Adds tests for container service request validation and lazy dependency error paths. |
| cli/azd/internal/grpcserver/compose_service_coverage3_test.go | Adds tests for compose service error paths and basic happy-path resource add/list/get. |
| cli/azd/internal/grpcserver/ai_model_service_coverage3_test.go | Adds request validation and error mapping tests for AI model gRPC service. |
| cli/azd/internal/grpcserver/account_service_coverage3_test.go | Adds request validation test for account lookup tenant. |
| cli/azd/cmd/util_coverage3_test.go | Adds tests around CLI utilities (browser override, service warnings, annotations/types). |
| cli/azd/cmd/templates_coverage3_test.go | Adds tests for template source list/add/remove actions using mocks and formatters. |
| cli/azd/cmd/extrun_coverage3_test.go | Adds arg-validation tests for extension actions and various command constructors. |
| cli/azd/cmd/extension_coverage3_test.go | Adds tests for semver parsing and namespace conflict logic. |
| cli/azd/cmd/envremove_coverage3_test.go | Adds tests for env remove flows and args validation paths. |
| cli/azd/cmd/container_coverage3_test.go | Adds tests for lazy environment resolver and action registration/resolution helpers. |
| cli/azd/cmd/constructors_coverage3_test.go | Adds broad constructor smoke tests spanning many command/actions and consent parsing helpers. |
| cli/azd/cmd/actions_coverage3_test.go | Adds constructor smoke tests for many actions/utilities to cover field assignments and init paths. |
- Add missing copyright headers to 23 files - Fix struct field alignment via go fix (7 files) - Fix gofmt formatting (60+ files) - Fix gosec G306: change file permissions from 0o644 to 0o600 - Wrap lines exceeding 125 characters (~55 instances) - Remove unnecessary type assertions (staticcheck S1040) - Remove unused code (mockSource type, envLookup func) - Address Copilot review: fix parallel test race on global state, replace real browser invocation with mock, remove dead subtest, fix comment/assertion mismatch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix copyright headers to use two-line format expected by CI: Line 1: // Copyright (c) Microsoft Corporation. All rights reserved. Line 2: // Licensed under the MIT License. - Fix gosec G306 in round8 and service_target_appservice tests - Fix remaining long lines in managed_clusters, project_utils3, service_manager2 - Remove unused ptrStr function from copilot_service test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
wbreza
left a comment
There was a problem hiding this comment.
Code Review — Phase 3 Test Coverage Improvement
Impressive effort raising coverage from 42.8% to 58.0% across 5 major packages with 74 new test files. Several packages have excellent test quality — particularly pkg/project/, pkg/azapi/, and internal/grpcserver/ which demonstrate thorough error path coverage and proper use of Go 1.26 conventions.
✅ What Looks Good
pkg/project/— Consistently high quality: propert.Context(),t.TempDir(),t.Chdir(), meaningful assertionspkg/azapi/— Proper HTTP mock setup, specific error assertions, correctnew(val)usageinternal/grpcserver/— Excellent success/error path coverage, good lazy initialization testingpkg/pipeline/— Thorough mock provider implementations, comprehensive error path testing- CI gate raise from 55% → 58% is reasonable
Summary
| Priority | Count |
|---|---|
| Critical | 1 |
| High | 2 |
| Medium | 2 |
| Low | 1 |
| Total | 6 |
Overall Assessment: Comment — a few patterns worth addressing to strengthen test quality. See inline comments.
…sts, t.Context() - Replace constructor-only smoke tests with field-level assertions (actions_coverage3) - Fix environment-dependent tests by unsetting CI env vars (final_coverage3) - Add proper error assertions for discarded results (env_coverage3) - Replace 504 context.Background() calls with t.Context() across 25 files - Fix non-deterministic SaveConfigError test with specific error assertion - Convert prompt_service tests to table-driven pattern Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Phase 3: Test coverage improvement
Raises unit-only statement-weighted coverage from 42.8% to 58.0% (+15.2 pp) across the 5 largest uncovered packages. CI gate raised from 55% to 58%.
Package improvements
cmdpkg/projectpkg/azapipkg/pipelineinternal/grpcserverTotals: 74 new test files, ~29,000 lines of tests
What's covered
Run()error paths, utility functions, action methods (env, config, update, template, container, copilot, extensions)mergeProjectVariablesAndSecrets, pipeline file generationCI gate change
eng/pipelines/release-cli.yml:MinimumCoveragePercent55 -> 58Test file naming
All new files use
_coverage3_test.gosuffix to distinguish from existing tests and Phase 2's_coverage2_test.gofiles.Validation
go test ./... -shortmage coverage:unitconfirms 58.0% overall, 68.3% package average