Skip to content

Tests: Add unit tests for all provisioning extension components #7480

@wbreza

Description

@wbreza

Summary

Write comprehensive unit tests for all new provisioning extension components: envelope, manager, external provider adapter, gRPC service handler, and provider validation.

Parent Epic

Part of #7465 — Provisioning Providers in the AZD Extension Framework

Context

Follow the testing patterns established by existing extension tests in the codebase. Each component needs tests that verify its behavior in isolation with appropriate mocking.

Detailed Requirements

1. ProvisioningEnvelope Tests

  • GetRequestId / SetRequestId correctly manipulate request_id
  • GetError / SetError correctly wrap/unwrap ExtensionError
  • GetInnerMessage extracts correct oneof payload for each message type
  • IsProgressMessage returns true only for Deploy/Preview/Destroy progress messages
  • GetProgressMessage extracts progress text
  • CreateProgressMessage creates valid progress message

2. ProvisioningManager Tests

  • onInitialize creates provider via factory, calls Initialize()
  • onDeploy / onPreview / onDestroy forward progress callbacks correctly
  • onState / onEnsureEnv / onParameters delegate to provider correctly
  • Registration sends correct proto message and handles response
  • Error from provider is propagated correctly

3. ExternalProvisioningProvider Tests

  • Mock the MessageBroker
  • Verify correct proto messages are constructed for each method
  • Verify SendAndWait vs SendAndWaitWithProgress usage
  • Verify proto → core type conversions (outputs, resources, parameters, preview changes)
  • Handle nil/empty responses gracefully

4. ProvisioningService Tests

  • Capability check rejects extensions without provisioning-provider capability
  • Registration creates correct IoC entry
  • Provider name used as IoC key
  • Stream cleanup removes broker from map

5. ParseProvider Tests

  • Accepts arbitrary strings ("myprov", "pulumi", "cdk")
  • Known values (Bicep, Terraform, Test) still work
  • Empty string (NotSpecified) defaults correctly
  • Verify Config field serialization

Acceptance Criteria

  • Envelope tests cover all 8 interface methods
  • Manager tests cover all 7 handlers plus registration
  • External provider tests mock broker and verify all methods
  • gRPC service tests verify capability check and IoC registration
  • ParseProvider tests verify arbitrary string acceptance
  • All tests pass with go test ./... for affected packages
  • Test coverage ≥80% for new code

Dependencies

Files

  • Create: pkg/azdext/provisioning_envelope_test.go
  • Create: pkg/azdext/provisioning_manager_test.go
  • Create: pkg/infra/provisioning/external/external_provider_test.go
  • Create: internal/grpcserver/provisioning_service_test.go
  • Modify: pkg/infra/provisioning/provisioning_test.go

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions