Skip to content

[quality] test: add unit tests for countme package#67

Open
hanthor-hive-agent[bot] wants to merge 2 commits into
mainfrom
quality/test-countme
Open

[quality] test: add unit tests for countme package#67
hanthor-hive-agent[bot] wants to merge 2 commits into
mainfrom
quality/test-countme

Conversation

@hanthor-hive-agent

Copy link
Copy Markdown

Test Improvement

Add comprehensive unit tests for the Fedora countme protocol implementation (internal/countme/countme.go).

Tests added

  • Time window arithmetic: TestWindowNumber, TestWindowToUnix, TestWindowRoundTrip — edge cases at window boundaries and round-trip verification
  • Age bucket computation: TestAgeBucket — all bucket transitions (1→2→3→4) and boundary conditions
  • User-Agent generation: TestUserAgent, TestUserAgentVersion — format, version embedding, variant detection
  • Arch/OS mapping: TestBaseArch, TestGoosName — RPM convention mapping
  • State persistence: TestLoadState_* (4 tests), TestSaveAndLoadState, TestSaveState_Disabled` — valid JSON, corrupt JSON, missing files, atomic write
  • Status formatting: TestStatusString_OptOutEnvVar, TestStatusString_Formatting
  • Edge cases: Large timestamps, negative windows, far-future buckets

Fixes #66


Filed by quality agent (ACMM L4/L6 — full mode)

Add comprehensive unit tests for the Fedora countme protocol implementation:

- windowNumber()/windowToUnix() time window arithmetic with round-trip
- ageBucket() bucket computation at all boundary conditions
- userAgent() format and version embedding
- baseArch() and goosName() OS/arch mapping
- loadState()/saveState() persistence (valid, corrupt, missing files)
- StatusString() formatting
- Edge cases for large timestamps and negative windows

Fixes #66

Signed-off-by: Quality Agent <quality@hive.local>
Signed-off-by: hive-outreach-agent <outreach@hive.tunaos>
@hanthor-hive-agent hanthor-hive-agent Bot added the enhancement New feature or request label Jun 28, 2026
- Fix windowNumber test: epoch 0 gives window 0, not -5
  (Go integer division rounds toward zero)
- Fix ageBucket test: step=10 gives bucket 3, not 1
  (curWindow - epochWindow = 0 - (-10) = 10, which is ≥ 5, putting it in bucket 3)
- Fix lint: check saveState error return value in TestSaveState_Disabled

Signed-off-by: hive-outreach-agent <outreach@hive.tunaos>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] countme: Fedora countme protocol implementation has zero unit tests

0 participants