E535 [Repo Assist] Test: add UniqueNameGenerator unit tests by github-actions[bot] · Pull Request #319 · fsprojects/SwaggerProvider · GitHub
[go: up one dir, main page]

Skip to content

[Repo Assist] Test: add UniqueNameGenerator unit tests#319

Merged
sergey-tihon merged 2 commits intomasterfrom
repo-assist/test-unique-name-generator-2026-03-11-90443b2c3b139800
Mar 11, 2026
Merged

[Repo Assist] Test: add UniqueNameGenerator unit tests#319
sergey-tihon merged 2 commits intomasterfrom
repo-assist/test-unique-name-generator-2026-03-11-90443b2c3b139800

Conversation

@github-actions
Copy link
Contributor

🤖 This is a pull request from Repo Assist, an automated AI assistant.

Summary

Task 9 — Testing Improvement: UniqueNameGenerator (in src/SwaggerProvider.DesignTime/Utils.fs) is used by all four compilers (v2/v3 DefinitionCompiler and OperationCompiler) to de-duplicate property and method names within each generated type scope — but it had no unit tests at all.

What's tested

10 new [(Fact)] tests in tests/SwaggerProvider.Tests/UtilsTests.fs:

Test Description
First use unchanged "Foo""Foo"
Second use suffixed "Bar", "Bar""Bar", "Bar1"
Third use suffixed increments to "Bar2"
Case-insensitive collisions "Foo" then "foo""foo1"
Original casing preserved returned name keeps input case
Suffix casing follows input "myMethod""myMethod1"
No false collisions different names don't interfere
Sequential suffixes X, X1, X2, X3, X4
Name-suffix chaining after Op and Op1 are taken, Op1Op11
Empty string """", then """1"

Why this matters

A regression in UniqueNameGenerator (e.g., if the case-insensitivity logic broke) would silently produce duplicate property names in generated types, causing compile errors in user code. These tests pin down the documented behaviour.

Test Status

  • dotnet build SwaggerProvider.sln -c Release — 0 errors
  • dotnet tests/SwaggerProvider.Tests/bin/Release/net10.0/SwaggerProvider.Tests.dll190 passed (180 → 190, +10 new tests), 0 failed, 2 skipped
  • dotnet fantomas tests/SwaggerProvider.Tests/UtilsTests.fs --check — format clean

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

UniqueNameGenerator is used in all v2/v3 DefinitionCompilers and
OperationCompilers to de-duplicate property and method names within
each generated type scope — but had no dedicated tests.

Add 10 tests covering:
- first/second/nth use of the same name
- case-insensitive collision detection
- casing preservation in returned names
- sequential numeric suffixes (X, X1, X2, ...)
- name-suffix chaining edge case (Op → Op1 → Op1 collision → Op11)
- empty-string input

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review March 11, 2026 18:02
Copilot AI review requested due to automatic review settings March 11, 2026 18:02
@sergey-tihon sergey-tihon merged commit 1414fd1 into master Mar 11, 2026
3 checks passed
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds unit test coverage for UniqueNameGenerator to lock in its de-duplication behavior (used across v2/v3 definition & operation compilers) and prevent regressions that could lead to generated duplicate member names.

Changes:

  • Added 10 new xUnit tests covering suffixing, case-insensitive collisions, and edge cases (including empty string).
  • Included the new test file in the test project compilation list.

Reviewed changes

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

File Description
tests/SwaggerProvider.Tests/UtilsTests.fs Adds a dedicated UniqueNameGenerator test module with 10 facts covering expected uniqueness behavior.
tests/SwaggerProvider.Tests/SwaggerProvider.Tests.fsproj Adds UtilsTests.fs to the compile items so the new tests run in CI/local.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +45 to +46
// Suffix is appended to the original input, preserving its casing
gen.MakeUnique "myMethod" |> shouldEqual "myMethod1"
Copy link
Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The test suffix casing follows the input not the stored key doesn’t currently exercise the scenario described by its name/comment: both calls use the same casing ("myMethod"), and the suffix is numeric so casing can’t differ. Consider changing the second call to a different-cased input (e.g., first "myMethod" then "MYMETHOD" expecting "MYMETHOD1"), or renaming the test to match what it actually asserts.

Suggested change
// Suffix is appended to the original input, preserving its casing
gen.MakeUnique "myMethod" |> shouldEqual "myMethod1"
// Suffix is appended to the current input ("MYMETHOD"), preserving its casing
gen.MakeUnique "MYMETHOD" |> shouldEqual "MYMETHOD1"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0