azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Migrate unit tests from Azure.Functions.Cli.Tests to Func.Unit.Tests

Open Copilot opened this issue 5 months ago • 2 comments

This PR migrates pure unit tests from the test/Azure.Functions.Cli.Tests project to the dedicated test/Cli/Func.Unit.Tests project. The goal is to separate unit tests (which test individual components in isolation) from integration/E2E tests (which use CliTester or run the full CLI).

Changes Made

Migrated Unit Tests (20 files total)

  • Helper utilities: TestUtils.cs, Extensions.cs
  • Core functionality tests:
    • KubernetesHelperUnitTests.cs - Kubernetes name validation and YAML serialization
    • UtilitiesTests.cs - Configuration and logging utility methods
    • AzureHelperTests.cs - Azure function key retrieval (with mocked HTTP)
    • RequirementsTxtParserTests.cs - Python requirements.txt parsing logic
    • GitIgnoreParserTests.cs - Git ignore pattern matching
    • CommandCheckerFacts.cs - Command existence validation
    • ColoredConsoleLoggerTests.cs - Console logging functionality
    • LoggingFilterHelperTests.cs - Log filtering logic
    • KedaHelperUnitTests.cs - KEDA metadata population for v1/v2
    • HostHelperTests.cs - Custom handler executable detection
  • Extension method tests:
    • StringExtensionsTests.cs - String sanitization methods
    • UriExtensionsTests.cs - URI server status checking
    • TaskExtensionsTests.cs - Task failure handling extensions
    • GenericExtensionsTests.cs - Generic object merging extensions
    • ProcessExtensionsTests.cs - Process wait extensions
  • Action tests:
    • ResolveActionTests.cs - Command line argument parsing and action resolution

Project Updates

  • Updated Azure.Functions.Cli.Unit.Tests.csproj with required NuGet package references:
    • Added Newtonsoft.Json, NSubstitute, RichardSzalay.MockHttp, SuaveServerWrapper, Xunit.SkippableFact
  • Updated all migrated tests to use the Azure.Functions.Cli.Unit.Tests namespace

Verification

  • All migrated tests are true unit tests that don't depend on CliTester or external CLI execution
  • No E2E or integration tests were accidentally moved
  • Tests remain functionally identical, only the project location and namespace changed
  • Removed migrated files from the original test project to avoid duplication

The remaining tests in Azure.Functions.Cli.Tests are primarily E2E tests that use CliTester or require running the full CLI, which is appropriate for that project.

Fixes #4474.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azfunc.pkgs.visualstudio.com
    • Triggering command: dotnet build --verbosity quiet (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Jun 18 '25 22:06 Copilot

/azp run

liliankasem avatar Jun 18 '25 22:06 liliankasem

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jun 18 '25 22:06 azure-pipelines[bot]

/azp run

liliankasem avatar Jul 08 '25 18:07 liliankasem

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 08 '25 18:07 azure-pipelines[bot]

/azp run

liliankasem avatar Jul 08 '25 22:07 liliankasem

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Jul 08 '25 22:07 azure-pipelines[bot]