Skip to content

refactor: migrate test suite from Ginkgo v1 to v2#1111

Open
ramonskie wants to merge 4 commits intomasterfrom
ginkgo-v2
Open

refactor: migrate test suite from Ginkgo v1 to v2#1111
ramonskie wants to merge 4 commits intomasterfrom
ginkgo-v2

Conversation

@ramonskie
Copy link
Contributor

@ramonskie ramonskie commented Mar 2, 2026

Summary

This PR migrates the ruby-buildpack test suite from Ginkgo v1 to v2.

Commits

Commit 1 – migrate to ginkgo v2
Upgrade `github.com/onsi/ginkgo` v1.16.5 → v2 and update all import paths from `github.com/onsi/ginkgo` to `github.com/onsi/ginkgo/v2`. Runs `go mod tidy` and `go mod vendor` to bring in updated dependencies.

Commit 2 – refactor: migrate Ginkgo v1 AfterEach cleanup to v2 DeferCleanup
Replace all `AfterEach` cleanup blocks with `DeferCleanup` calls co-located in `BeforeEach`/`JustBeforeEach`, following Ginkgo v2 idioms. Bare `AfterEach` at `Describe`-level are replaced with direct `DeferCleanup` calls in the `Describe` body. `mockCtrl.Finish()` calls are removed (auto-handled by `GinkgoT()` in v2).

Files changed:

  • `src/ruby/cache/cache_test.go`
  • `src/ruby/finalize/finalize_test.go`
  • `src/ruby/finalize/release_test.go`
  • `src/ruby/supply/supply_test.go`
  • `src/ruby/versions/ruby_test.go`

Commit 3 – fix: install ginkgo v2 CLI in unit test script
`scripts/.util/tools.sh` was installing the Ginkgo v1 CLI (`github.com/onsi/ginkgo/ginkgo`). Updated to install the v2 CLI (`github.com/onsi/ginkgo/v2/ginkgo`).

Commit 4 – fix: resolve go vet non-constant format string errors and bare DeferCleanup
Ginkgo v2 runs `go vet` before executing tests (v1 did not). This surfaced pre-existing non-constant format string errors in production source files where a variable was passed directly as the format argument to `Logger.Error`, `Logger.Warning`, and `Logger.Debug`. Fixed by adding `"%s"` as the format verb and passing the variable as the argument, or by inlining `fmt.Sprintf` calls directly into the logger call.

Additionally, two `DeferCleanup` calls in `supply_test.go` were placed directly in `Describe` container bodies (not inside a setup node). Ginkgo v2 panics at runtime when `DeferCleanup` is called outside a setup or subject node. Fixed by wrapping them in `BeforeEach`.

Files changed:

  • `src/ruby/cache/cache.go`
  • `src/ruby/finalize/finalize.go`
  • `src/ruby/supply/supply.go`
  • `src/ruby/supply/supply_test.go`

Verification

  • `./scripts/unit.sh` ✅
  • Zero `AfterEach` remaining in source ✅

Upgrade github.com/onsi/ginkgo v1.16.5 -> v2 and update all import
paths from github.com/onsi/ginkgo to github.com/onsi/ginkgo/v2.
Replace all AfterEach cleanup blocks with DeferCleanup calls co-located
in BeforeEach/JustBeforeEach, following Ginkgo v2 idioms. Bare AfterEach
at Describe-level are replaced with direct DeferCleanup calls in the
Describe body.
Update ginkgo install path from github.com/onsi/ginkgo/ginkgo to
github.com/onsi/ginkgo/v2/ginkgo so the correct CLI is used with v2 test suites.
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