Skip to content

Add unit tests for the starter/runner core logic (leverage the unused memory datastore as a fake) #261

Description

@whywaita

Problem

The core of the system is untested. Of 63 non-test Go files, only 3 packages have tests (pkg/datastore/mysql, pkg/gh, pkg/web). pkg/starter (589 lines) and pkg/runner have zero tests, including the runner-deletion safety valve.

Highest-value, lowest-cost targets (pure functions)

  • sanitizeRunner / sanitizeRunnerMustRunningTime / sanitizeGitHubRunner (pkg/runner/runner_delete.go:213-241) — these decide whether a runner may be deleted; a bug here can force-delete a runner with a running job.
  • extractWorkflowIDs (pkg/starter/starter.go:193)
  • ExtractRunsOnLabels (pkg/gh/webhook.go:35) — called from 4 sites.
  • labelsToOneLine (pkg/starter/scripts.go:124), ToName/ToUUID/ToReason (pkg/runner/util.go), GetRunnerTemporaryMode (pkg/runner/runner.go:102).

Enabler: revive the unused memory datastore

pkg/datastore/memory/memory.go implements the Datastore interface but is referenced from nowhere (dead code). Using it as a fake would let Starter.ProcessJob (pkg/starter/starter.go:212) be tested without a MySQL container.

Existing test bug to fix along the way

pkg/web/target_test.go:578 uses if strings.EqualFold(test.want, got) — it fails on a match, i.e. the condition is inverted, so the error-response assertion is effectively disabled. Should be !strings.EqualFold(...).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions