Skip to content

Refactor core/domain + config, harden tests/auth, fix CI (ISOLATED_TEST gate) - #16

Merged
neoRandom merged 10 commits into
mainfrom
development
Aug 24, 2026
Merged

Refactor core/domain + config, harden tests/auth, fix CI (ISOLATED_TEST gate)#16
neoRandom merged 10 commits into
mainfrom
development

Conversation

@neoRandom

Copy link
Copy Markdown
Owner

No description provided.

- Remove hallucinated password-equals-username assertions in authentication_test.go (rule was never implemented; tests passed due to unrelated length/whitespace checks)
- Delete two no-op tests that discarded results without asserting
- Fix CLI dispatch: "data" -> "fetch" to match documented noun in usage string and README; add regression test

Verified: go test ./... and go vet ./... pass.
- Add plain domain types in internal/core/model (Game, Player,
  Interaction with time.Time OccurredAt, *int64 for nullable refs)
  with zero infrastructure imports
- Add internal/infrastructure/database/mapping package for
  DB->domain conversion (interaction mapping parses timestamps,
  fails fast with no partial results on error)
- Retype core/port/driver.go and driven.go against domain types
- Simplify core/service/shared_data.go: drop timestamp parsing and
  constant/database imports, compare time.Time directly
- Update use cases to map DB->domain on return; fix inconsistent
  error wrapping so ListInteractions/ListPlayerInteractions match
  the context-prefix convention used elsewhere
- Update adapters (JWT, HTTP DTOs) and tests for domain types;
  remove dead nullableInt64 helper

internal/core now has zero imports of internal/infrastructure.
No repository layer introduced; use cases still query
*database.Queries directly, unchanged from prior design.

Verified: go build, go vet, go test -count=1 ./... all pass.
…ase B)

- core/service/authentication_test.go: merge password-validity and
  hash tests into two table-driven tests (7 -> 2)
- usecase/game_management_test.go: collapse CRUD, nil-dependency,
  invalid-ID, name-validation, and cancelled-context tests into
  5 table-driven tests (17 -> 5)
- usecase/player_management_test.go: collapse nil-dependency,
  cancelled-context, and input-validation tests (24 -> 14); also
  removes a second, previously-unflagged instance of the hallucinated
  password-equals-username assertions found in
  TestPlayerManagement_TrimPasswordWhitespaceBeforeStorage
- Extract internal/testutil (FindMigrationsDir, NewTestDB,
  ReadGameNameByAccess) from duplicated helpers in
  usecase/test_helpers_test.go and database/queries_test.go
- Convert database/queries_test.go to package database_test to
  avoid a database <-> testutil import cycle

No production logic changed except by the removals noted above.
Verified: go test ./... and go vet ./... pass.

Known issue (not fixed here): IsPasswordValid checks only literal
space characters, not general whitespace, despite its error message
implying broader whitespace rejection. Tracked for follow-up.
- IsPasswordValid now rejects any non-[A-Za-z0-9] byte/rune (spaces, tabs, newlines, punctuation, and multi-byte/Unicode characters) instead of only rejecting a literal space.

- Update the error message to "password may only contain letters and digits" and align the boundary test table, adding tab/newline, punctuation, and multi-byte cases that were false-passes under the old check.

- Update the use-case test comment/messages to match the real rule.
…dit Phase D)

- application/model: JwtPlayerClaims is a plain struct (no jwt embed); JWT (de)serialization moved to the driven adapter (JwtClaims + ParseToken).
- httpadapter: echo-jwt now parses into driven.JwtClaims.
- usecase: GameCommands returns ErrCannotSaveWhilePaused/ErrCannotPause/ ErrCannotResume sentinels instead of raw SQLite trigger strings.
- httpadapter: commandError maps conflicts via errors.Is; conflictStatusFromErr removed.
@neoRandom
neoRandom merged commit 7a34151 into main Aug 24, 2026
1 check 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.

1 participant