Skip to content

Expand Cosmos Emulator tests and harden read extension validation#18

Draft
Copilot wants to merge 33 commits into
mainfrom
copilot/add-integration-tests-cosmos-emulator-again
Draft

Expand Cosmos Emulator tests and harden read extension validation#18
Copilot wants to merge 33 commits into
mainfrom
copilot/add-integration-tests-cosmos-emulator-again

Conversation

Copy link
Copy Markdown

Copilot AI commented May 23, 2026

This PR expands Cosmos Emulator integration coverage and incorporates review-driven fixes in both tests and read extension behavior.

Changes Made

  • Expanded and reorganized operation/read integration tests with scenario-based seeding using DatabaseTestApplicationFactory derivatives (SingleItemScenario, MultipleItemsScenario).
  • Refactored integration test infrastructure to support generic IntegrationTestBase<'DatabaseTestApplicationFactory> / OperationTestBase<'DatabaseTestApplicationFactory> patterns.
  • Added shared TestCategories constants and applied explicit TestCategory attributes across test classes.
  • Updated IsNotDeletedAsync in Cosmos.fs:
    • changed deletedFieldName to non-nullable string,
    • kept an explicit runtime nullArg guard,
    • retained strict identifier validation for invalid field names,
    • corrected requestOptions parameter naming.
  • Added XML <exception> documentation for methods that throw in Cosmos.fs (IsNotDeletedAsync, AddPreTriggers, AddPostTriggers).
  • Expanded read extension integration coverage for deleted-field-name validation and behavior, including:
    • null/empty/whitespace invalid inputs,
    • invalid start and invalid character cases,
    • valid underscore and digit-in-body field names,
    • verification that setting a valid digit-containing deleted marker changes IsNotDeletedAsync result as expected.
  • Formatted updated F# files with Fantomas.

Validation

  • dotnet build FSharp.Azure.Cosmos.slnx
  • dotnet test FSharp.Azure.Cosmos.slnx
  • dotnet test tests/Cosmos.Tests/FSharp.Azure.Cosmos.Tests.fsproj
  • dotnet test tests/Cosmos.Tests/FSharp.Azure.Cosmos.Tests.fsproj --filter "FullyQualifiedName~ReadExtensionsIntegrationTests"
  • Final automated validation checks passed (code review + security scan).

Copilot AI linked an issue May 23, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add integration tests against Cosmos Emulator Add Cosmos Emulator integration test foundation and scoped scenario plan May 23, 2026
Copilot AI requested a review from xperiandri May 23, 2026 18:31
Copy link
Copy Markdown
Collaborator

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

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

Fix and format with Fantomas according to your instructions

Comment thread tests/Cosmos.Tests/IntegrationInfrastructure.fs Outdated
Comment thread tests/Cosmos.Tests/IntegrationInfrastructure.fs Outdated
Comment thread tests/Cosmos.Tests/IntegrationInfrastructure.fs Outdated
Comment thread tests/Cosmos.Tests/IntegrationTestPlan.fs Outdated
Comment thread tests/Cosmos.Tests/IntegrationInfrastructure.fs Outdated
Copilot AI requested a review from xperiandri May 24, 2026 00:16
Copilot AI changed the title Add Cosmos Emulator integration test foundation and scoped scenario plan Add Cosmos Emulator integration tests for core operations May 24, 2026
Comment thread tests/Cosmos.Tests/Tests.fs Outdated
Copilot AI requested a review from xperiandri May 24, 2026 01:22
Copilot AI changed the title Add Cosmos Emulator integration tests for core operations Expand Cosmos Emulator tests for operations, read extensions, and builders May 24, 2026
@xperiandri xperiandri force-pushed the copilot/add-integration-tests-cosmos-emulator-again branch from 542f3fc to d5b9617 Compare May 24, 2026 14:48
Copilot AI and others added 20 commits May 25, 2026 00:56
Co-authored-by: Andrii Chebukin <XperiAndri@Outlook.com>
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Azure.Cosmos/sessions/b2eda2fa-a0cb-4604-b8ca-51bd73075963

Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
@xperiandri xperiandri force-pushed the copilot/add-integration-tests-cosmos-emulator-again branch from 2a78e83 to bde1f0d Compare May 24, 2026 22:56
Comment thread src/Cosmos/Cosmos.fs
$"""SELECT VALUE COUNT(1)
FROM item
WHERE item.id = @Id
AND (NOT IS_DEFINED(item.{deletedFieldName}) OR IS_NULL(item.{deletedFieldName}))"""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot так что с покрытием всех этих кейсов тестами?

Comment thread src/Cosmos/Cosmos.fs Outdated
Comment on lines +218 to +225
(deletedFieldName : string | null)
(id : string, [<Optional>] requiestOptions : QueryRequestOptions, [<Optional>] cancellationToken : CancellationToken)
=
task {
let deletedFieldName =
match deletedFieldName with
| null -> nullArg (nameof deletedFieldName)
| deletedFieldName -> deletedFieldName
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot ты понимаешь что это идиотизм декларировать string | null а потом кидать исключение.

Suggested change
(deletedFieldName : string | null)
(id : string, [<Optional>] requiestOptions : QueryRequestOptions, [<Optional>] cancellationToken : CancellationToken)
=
task {
let deletedFieldName =
match deletedFieldName with
| null -> nullArg (nameof deletedFieldName)
| deletedFieldName -> deletedFieldName
(deletedFieldName : string)
(id : string, [<Optional>] requiestOptions : QueryRequestOptions, [<Optional>] cancellationToken : CancellationToken)
=
if deletedFieldName |> withNull |> isNull then
nullArg (nameof deletedFieldName)
task {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Исправил в 69776da (уточнение в 1a73340): сигнатура теперь deletedFieldName : string, при этом runtime guard оставлен через nullArg для null-входа.

Comment thread src/Cosmos/Cosmos.fs
@@ -215,15 +215,41 @@ module Operations =
/// <param name="partitionKey">Partition key</param>
/// <param name="cancellationToken">Cancellation token</param>
member container.IsNotDeletedAsync
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot <exception XML комментарии добавь на все методы где они вылетают

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Добавил XML <exception> в 69776da для методов, где выбрасываются исключения: IsNotDeletedAsync, AddPreTriggers, AddPostTriggers.

Copilot AI requested a review from xperiandri May 24, 2026 23:15
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.

Integration tests against Cosmos Emulator

3 participants