Files
quyun-v2/docs/plans/2026-02-04.md

3.2 KiB

Implementation Plan: backend-test-coverage

Branch: [test-coverage-t3-t4] | Date: 2026-02-04 | Spec: N/A Input: Continuation of test coverage tasks (T3/T4) from prior session; no feature spec.

Summary

Complete backend service test coverage for content access policies (T3) and superadmin write operations (T4), ensuring existing behavior is validated without altering production logic.

Technical Context

Language/Version: Go 1.x (project standard)
Primary Dependencies: Fiber, GORM-Gen, Testify
Storage: PostgreSQL (via GORM)
Testing: go test (service tests under backend/app/services/*_test.go)
Target Platform: Linux server
Project Type: Web application (frontend + backend)
Performance Goals: N/A (test-only changes)
Constraints: No changes to generated files; keep tests aligned with existing service patterns
Scale/Scope: Backend service tests only (no frontend scope)

Constitution Check

  • Follow backend/llm.txt for backend conventions.
  • Keep controllers thin; service tests only (no controller edits).
  • Avoid editing generated files (routes.gen.go, docs.go).
  • Run go test for impacted service packages.

Project Structure

Documentation (this feature)

specs/[###-feature]/
└── (not used for this task)

Source Code (repository root)

backend/
├── app/
│   ├── services/
│   │   ├── content_test.go
│   │   └── super_test.go
└── app/http/v1/dto/
    └── content.go

Structure Decision: Web application structure; scope is backend service tests in backend/app/services.

Plan Phases

  1. Inspect DTO definitions used by content tests to fix T3 assertions.
  2. Implement remaining content access policy tests (T3) and verify via go test.
  3. Implement superadmin write operation tests (T4) and verify via go test.

Tasks

  1. Read backend/app/http/v1/dto/content.go and update T3 test assertions to match actual DTO fields.
  2. Extend backend/app/services/content_test.go with missing content access policy cases and run targeted tests.
  3. Extend backend/app/services/super_test.go for superadmin write operations; run service test suite.
  4. Verify all added tests pass without modifying production logic.

Dependencies

  • Task 1 must complete before Task 2 (DTO fields drive assertions).
  • Task 2 should complete before Task 3 to isolate failures.

Acceptance Criteria

  • backend/app/services/content_test.go has passing T3 coverage for unauthenticated access constraints.
  • backend/app/services/super_test.go includes T4 coverage for create-tenant side effects and superadmin write operations.
  • go test ./backend/app/services/... passes.
  • No generated files modified.

Risks

  • DTO field changes may require adjusting test assertions; mitigate by verifying struct definitions.
  • Service behavior may differ from assumptions in prior session; mitigate by aligning with existing tests.

Complexity Tracking

Fill ONLY if Constitution Check has violations that must be justified

Violation Why Needed Simpler Alternative Rejected Because
N/A N/A N/A