Skip to content

Increase code coverage in unit test pipeline#3703

Open
aaronburtle wants to merge 8 commits into
mainfrom
dev/aaronburtle/improve-code-coverage
Open

Increase code coverage in unit test pipeline#3703
aaronburtle wants to merge 8 commits into
mainfrom
dev/aaronburtle/improve-code-coverage

Conversation

@aaronburtle

@aaronburtle aaronburtle commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

Related to: #3648

What is this change?

Improves branch coverage by adding fast, database-free unit tests for pure-logic classes that were previously at 0% or very low coverage. No product/runtime behavior is changed.

Adds ~300 unit test methods (500+ cases including [DataRow] variations) across 35 files, all running in the existing unit-test job

  • Config JSON converters & model: EmbeddingsOptions, DmlToolsConfig, AKVRetryPolicy, AzureKeyVault, Compression, Bool, RuntimeCache/Level2 converters; EmbeddingsEndpointOptions role resolution; DeserializationVariableReplacementSettings (env + local @akv file resolution).
  • MCP tooling: non-DB validation paths for the built-in create/read/update/delete_record tools (tool-disabled, invalid args, metadata failures); McpArgumentParser, McpJsonHelper, McpResponseBuilder, McpErrorHelpers, McpAuthorizationHelper, McpMetadataHelper, and McpTelemetryHelper.
  • Core helpers/parsers/extensions: TypeHelper, EnumExtensions, Utf8JsonReaderExtensions, HttpStatusCodeExtensions, ProductInfo, and MergeJsonProvider.
  • GraphQL builder: GraphQLNaming, GraphQLUtils, GraphQLStoredProcedureBuilderHelpers, SchemaConverter type mapping, and EdmModelBuilder.
  • REST / OpenAPI & request validation: OpenApiDocumentor, and RequestValidator (static + instance) paths.
  • Runtime config validation: RuntimeConfigValidator and RuntimeConfigProvider logic.
  • SQL pure-logic helpers: SqlPaginationUtil and SqlResponseHelpers (mutation) paths.

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

N/A

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR increases unit-test/branch coverage by adding database-free tests for pure-logic helpers, config JSON converters, and MCP tooling validation paths, without changing product/runtime behavior.

Changes:

  • Adds unit tests for multiple config JSON converters (embeddings, cache, compression, Key Vault, DML tools, bool parsing, etc.).
  • Adds unit tests for core helper utilities/parsers (TypeHelper, enum parsing, JSON reader extensions, entity source parsing, merge-json).
  • Adds non-DB unit tests for MCP utilities and early-return validation/error paths in built-in DML tools.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Service.Tests/UnitTests/Utf8JsonReaderExtensionsTests.cs Covers string/null/non-string token handling for Utf8JsonReaderExtensions.DeserializeString.
src/Service.Tests/UnitTests/TypeHelperTests.cs Exercises TypeHelper type mappings and GraphQL value-node conversions.
src/Service.Tests/UnitTests/RuntimeCacheOptionsConverterTests.cs Verifies runtime cache (L1/L2) JSON read/write behavior and validation.
src/Service.Tests/UnitTests/ProductInfoTests.cs Tests ProductInfo version formatting and user-agent env-var behavior.
src/Service.Tests/UnitTests/MergeJsonProviderTests.cs Tests JSON merge semantics for objects/arrays/type mismatches/null overrides.
src/Service.Tests/UnitTests/HttpStatusCodeExtensionsTests.cs Validates HttpStatusCodeExtensions.IsClientError classification.
src/Service.Tests/UnitTests/EnumExtensionsTests.cs Tests enum parsing incl. EnumMember values and error messaging.
src/Service.Tests/UnitTests/EntitySourceNamesParserTests.cs Covers parsing/validation for schema.table inputs with bracket rules.
src/Service.Tests/UnitTests/EmbeddingsOptionsConverterTests.cs Tests embeddings options converter read/write, defaults, and invalid inputs.
src/Service.Tests/UnitTests/EmbeddingsEndpointOptionsTests.cs Verifies embeddings endpoint role-resolution and role-check logic.
src/Service.Tests/UnitTests/DmlToolsConfigConverterTests.cs Tests boolean/object forms for MCP DML tool configuration conversion.
src/Service.Tests/UnitTests/DeserializationVariableReplacementSettingsTests.cs Covers env-var replacement and local @akv file resolution logic.
src/Service.Tests/UnitTests/CompressionOptionsConverterTests.cs Tests compression options JSON read/write, defaults, and invalid values.
src/Service.Tests/UnitTests/BoolJsonConverterTests.cs Covers bool converter parsing of string/number representations and serialization.
src/Service.Tests/UnitTests/AzureKeyVaultOptionsConverterTests.cs Tests AKV options converter behavior incl. retry policy and validation.
src/Service.Tests/UnitTests/AKVRetryPolicyOptionsConverterTests.cs Tests AKV retry policy converter defaults, validation, and serialization.
src/Service.Tests/Mcp/McpTelemetryHelperTests.cs Tests MCP telemetry helper operation inference and exception→code mapping/wrapper behavior.
src/Service.Tests/Mcp/McpResponseBuilderTests.cs Tests MCP response builder success/error payloads and IActionResult JSON extraction.
src/Service.Tests/Mcp/McpJsonHelperTests.cs Tests JSON value conversion and engine-result extraction helpers.
src/Service.Tests/Mcp/McpErrorHelpersTests.cs Verifies standardized MCP error response shapes/messages.
src/Service.Tests/Mcp/McpAuthorizationHelperTests.cs Tests authorization helper behavior with mocked authorization resolver/HTTP context.
src/Service.Tests/Mcp/McpArgumentParserTests.cs Tests MCP argument parsing/validation for built-in tools and execute parameters.
src/Service.Tests/Mcp/BuiltInDmlToolValidationTests.cs Adds non-DB tests for built-in DML tool early validation/tool-disabled/metadata-failure branches.

Comment thread src/Service.Tests/Mcp/McpResponseBuilderTests.cs Outdated
Duplicates the existing EntitySourceNamesParserUnitTests, which already covers ParseSchemaAndTable comprehensively.
@aaronburtle aaronburtle changed the title Increase code coverage Increase code coverage in unit test pipeline Jul 8, 2026
@aaronburtle

Copy link
Copy Markdown
Contributor Author

@copilot can you review this again please, new tests have been added for additional coverage in the unit test pipeline.

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@copilot can you review this again please, new tests have been added for additional coverage in the unit test pipeline.

Reviewed the new tests. Build succeeds with 0 errors/warnings and all 151 new tests pass locally. A few observations on the additions:

OpenApiDocumentorUnitTests – The new tests thoroughly cover REST-disabled, read-only permissions, stored procedure, view, multi-entity, custom path, non-strict request body, and base-route scenarios. All look correct.

RuntimeConfigValidatorUnitTests – Good coverage of ValidateRestURI, ValidateGraphQLURI, ValidateMcpUri, ValidateAppInsightsTelemetryConnectionString, ValidateAzureLogAnalyticsAuth, ValidateFileSinkPath, ValidateEmbeddingsOptions, and ValidateGlobalEndpointRouteConfig. Assertions align with the validator's documented behavior.

RequestValidatorInstanceUnitTests – Covers CheckFirstValidity, ValidateRequestContext, ValidateInsertRequestContext (valid, missing-required, null-non-nullable, strict/non-strict, read-only), ValidateStoredProcedureRequestContext, and ValidateEntity. All look correct.

SqlResponseHelpersMutationUnitTests – Tests for OkResponse, OkMutationResponse, ConstructPrimaryKeyRoute, ConstructOkMutationResponse, and ConstructCreatedResultResponse look sound.

EdmModelBuilderTests – Correctly verifies that stored procedures and linking entities are skipped, and that a table entity creates an EDM entity type with the right key and property count.

McpResponseBuilderTests (from first commit) – The GetJsonValue_Number_PreservesNumericValue test now uses Convert.ToDecimal to compare, which correctly handles both long (from TryGetInt64) and double return paths without being type-specific.

No issues found — the tests are well-structured and appropriate for a coverage-improvement PR.

@aaronburtle aaronburtle moved this from Todo to Review In Progress in Data API builder Jul 9, 2026
@aaronburtle aaronburtle self-assigned this Jul 9, 2026
@aaronburtle aaronburtle added the testing Test related issue. label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test related issue.

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

5 participants