Skip to content

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

Merged
liliankasem merged 7 commits intomainfrom
copilot/fix-4474
Jul 9, 2025
Merged

Migrate unit tests from Azure.Functions.Cli.Tests to Func.Unit.Tests#4480
liliankasem merged 7 commits intomainfrom
copilot/fix-4474

Conversation

Copy link
Contributor

Copilot AI commented Jun 18, 2025

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 AI changed the title [WIP] Migrate unit tests Migrate unit tests from Azure.Functions.Cli.Tests to Func.Unit.Tests Jun 18, 2025
Copilot AI requested a review from liliankasem June 18, 2025 22:26
@liliankasem liliankasem marked this pull request as ready for review June 18, 2025 22:28
@liliankasem liliankasem requested a review from a team as a code owner June 18, 2025 22:28
@liliankasem
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liliankasem
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI and others added 7 commits July 8, 2025 14:27
Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
…aining unit tests

Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
Co-authored-by: liliankasem <2198905+liliankasem@users.noreply.github.com>
@liliankasem
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liliankasem liliankasem merged commit c816693 into main Jul 9, 2025
38 checks passed
@liliankasem liliankasem deleted the copilot/fix-4474 branch July 9, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate unit tests

4 participants