Skip to content

Improve test coverage for util package (0 tests, 451 LOC) #19

@BrewingCoder

Description

@BrewingCoder

Area

Backend — API / GraphQL

Category

Test coverage

Description

The util package is imported by 45 files and provides critical infrastructure (runtime modes, tracing, panic recovery, test DB setup) but has zero tests for its own code.

The irony: it provides RunTestWithDBWipe() and CreateAndMigrateTestDB() used by 12+ test files, but none of its own functions are tested.

Priority test targets:

  1. GetRuntime() — valid/invalid CLI flag combinations
  2. Runtime/Handler validation — IsValid(), IsPublicGraph(), IsWorker(), etc.
  3. GenerateRandomString() — length, character set
  4. JsonStringToStringArray() — valid JSON, invalid JSON, empty
  5. RestRequest() — success, HTTP errors, JSON decode errors
  6. MultiSpan tracing — Finish with/without error, SetAttribute, disabled context

See src/backend/util/MODULE.md for full analysis.

Affected Files / Packages

src/backend/util/runtime.go (84 lines — runtime mode system, no tests)
src/backend/util/tracer.go (119 lines — OTel span abstraction, no tests)
src/backend/util/tests.go (75 lines — test infra, no tests for itself)
src/backend/util/tracer-graphql.go (63 lines — GraphQL middleware, no tests)
src/backend/util/request.go (45 lines — HTTP client, no tests)
src/backend/util/recovery.go (27 lines — panic handlers, no tests)
src/backend/util/strings.go (23 lines — helpers, no tests)
src/backend/util/random.go (15 lines — random string, no tests)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions