Skip to content

Add automated test coverage for converters #2

Description

@samsonajulor

Context

We now have two converter plugins (Express, Flask) with zero automated tests. Both pass CI because there are no *_test.go files — go test ./... has nothing to run.

The Flask converter was merged in #1 based on manual testing. We need proper test coverage before adding more converters.

What's needed

internal/convert/convert_test.go (shared)

  • Test routeToHandlerName() with edge cases (nested paths, params, hyphens)
  • Test contains() helper
  • Test generateFromScan() produces valid Go that compiles

internal/convert/express_test.go

  • Create a temp directory with a minimal Express app (app.js, package.json, .env.example)
  • Run scanExpress() and assert: route count, methods, DB type, env vars, models
  • Verify generated output compiles: go build -o /dev/null .

internal/convert/flask_test.go

  • Create a temp directory with a minimal Flask app (app.py, requirements.txt, .env.example)
  • Run scanFlask() and assert: route count, methods, DB type, env vars, models
  • Test flaskPathToStandard(): <int:id>:id, <string:name>:name, <id>:id
  • Test extractMethods(): empty → ["GET"], 'GET', 'POST'["GET", "POST"]
  • Verify generated output compiles

Test fixtures

  • internal/convert/testdata/express/ — minimal Express app
  • internal/convert/testdata/flask/ — minimal Flask app

CI

  • go test ./... already runs in CI — just needs test files to exist
  • Add -race flag for race condition detection
  • Add -coverprofile for coverage reporting

Acceptance criteria

  • Every converter has at least one end-to-end test (scan → generate → compile)
  • Helper functions have unit tests
  • go test ./... actually tests something
  • CI reports coverage percentage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions