Skip to content

Fix stale validation-guard comment in the Todo sample controller tests - #19

Merged
xavierjohn merged 1 commit into
mainfrom
fix/stale-validation-guard-comment
Jul 4, 2026
Merged

Fix stale validation-guard comment in the Todo sample controller tests#19
xavierjohn merged 1 commit into
mainfrom
fix/stale-validation-guard-comment

Conversation

@xavierjohn

Copy link
Copy Markdown
Owner

CreateTodoCommandValidator is an empty showcase stub (its only content is a commented example of a DI/async rule), so the Create endpoint's controller tests were describing the missing-required-field guard incorrectly. The real guard is CreateTodoCommand.TryCreate(...)Result.Ensure(title is not null, ...) returns 422 before the handler runs.

Corrected the comment in both API-version test copies (2026-03-26 + 2026-12-01) to match the shipped code. Comment-only change; no behavior affected.

(Surfaced by a Copilot review of a scaffold generated from this template.)

The Create endpoint tests described the missing-required-field guard as CreateTodoCommandValidator.NotNull() in the FluentValidation pipeline, but CreateTodoCommandValidator is an empty showcase stub. The actual guard is CreateTodoCommand.TryCreate(...) — Result.Ensure(title is not null, ...) returns 422 before the handler runs. Corrected the comment in both API-version test copies to match the shipped code.

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the explanatory comment in the Todo sample controller tests to correctly describe where the “missing required field” guard happens (in CreateTodoCommand.TryCreate(...), not in CreateTodoCommandValidator), aligning the test narrative with the shipped implementation without changing behavior.

Changes:

  • Corrected the comment to reference CreateTodoCommand.TryCreate(...) as the source of the 422 guard for missing Title.
  • Applied the same correction to both API-versioned test snapshots (2026-03-26 and 2026-12-01).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
asp/template/Api/tests/2026-12-01/TodosControllerTests.cs Updates the missing-title guard comment to match the controller’s TryCreate(...) usage.
asp/template/Api/tests/2026-03-26/TodosControllerTests.cs Same comment correction in the older API-versioned test snapshot.

@xavierjohn
xavierjohn merged commit 8c175df into main Jul 4, 2026
5 checks passed
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.

2 participants