Skip to content

Test that Disabled() reports the environment when it opts out - #36

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/disabled-factory-environment-reason
Nov 13, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/disabled-factory-environment-reason

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle covering the TraceClient.Disabled() factory.

  • Disabled() builds its client through the same constructor as any other, and the constructor checks the environment before enabled: false. Under DO_NOT_TRACK=1 or TRACE_USAGE_REPORTING=off, its DisabledReason is therefore environment, not config. The only existing assertion (DisabledReason_NamesTheConfigFlagOrTheMissingKey) ran with a clean environment, so the other case was untested.
  • A characterization test, Disabled_SaysEnvironmentRatherThanConfigWhenTheEnvironmentOptsOut, is added. It also asserts that such a client is not enabled and has no InstallId.
  • The Disabled() XML doc now names both possible reasons. No behaviour, wire format, reason string or public signature is changed.

No tracking issue: the gap was found during triage. All three open issues were deferred because each one needs a maintainer's decision on the behaviour contract:

Test plan

  • CI Build passes on ubuntu-latest (net8.0) and windows-latest (net8.0 + net48), including the new test.
  • Only src/TraceClient/TraceClient.cs (XML doc comment only) and tests/TraceClient.Tests/TraceClientTest.cs are changed.

No .NET SDK could run in the dispatch sandbox, so local tests are UNVERIFIED. The CI matrix on the PR head is the test gate.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

TraceClient.Disabled() goes through the same constructor as any other
client, and the environment is checked before enabled: false. Under
DO_NOT_TRACK=1 its DisabledReason is therefore "environment", not
"config". The only existing assertion ran with a clean environment, so
pin the other case and say so in the factory's XML doc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (Phase 4, scored against the diff and CI run 43354680542):

  • Scope: PASS. Two files are changed: one XML doc comment on Disabled() and one new test. Neither has unrelated churn.
  • Tests-new: PASS. No public member is added. The new test exercises the existing Disabled() factory.
  • Tests-fix: N/A. This is characterization only, and production behaviour is unchanged.
  • Sibling structure: PASS. The test follows the neighbouring DisabledReason_* tests: the _environment seam, TraceClient.Reason* constants and the Subject_Behaviour name.
  • Sibling renames: N/A. Nothing is renamed.
  • Docs: PASS. The Disabled() XML doc now names both reasons. The README does not mention Disabled(), so no README row needs changing.
  • Issue resolution: N/A. No Closes, because the gap was found during triage.
  • CI: PASS. 120/120 passed on ubuntu net8.0, windows net8.0 and windows net48, up from 119 on main (run 43143463643), so the new test ran on every leg.
  • No dependencies / single file / vendoring floor: PASS. The csproj is untouched, no using is added, and src/TraceClient still holds only TraceClient.cs and TraceClient.csproj.
  • Never throws / non-blocking / environment seam / version / opt-out contract: PASS. No code path changed, and the reason strings and precedence are untouched.

Judgment calls:

  • tests/TraceClient.Tests/TraceClientTest.cs:390 — Assert.Null(client.InstallId) is weak evidence on its own. Disabled() never passes an install ID, so it would be null even without the opt-out. It is kept as a cheap guard in case the factory ever gains one.
  • Out of diff: README.md mentions Disabled() nowhere. The natural place for it is "Turning it off", which is a do-not-auto-merge section, so it was left for the maintainer.

Summary: a characterization test plus a doc comment. No contract surface is touched, the anchor is green on all three target legs, and no do-not-auto-merge path matches.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 452006e into main Nov 13, 2026
2 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/disabled-factory-environment-reason branch November 13, 2026 02:51
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.

1 participant