Skip to content

refactor: migrate test suite from Ginkgo v1 to v2 - #1148

Merged
tnikolova82 merged 4 commits into
masterfrom
ginkgo-v2
Mar 6, 2026
Merged

refactor: migrate test suite from Ginkgo v1 to v2#1148
tnikolova82 merged 4 commits into
masterfrom
ginkgo-v2

Conversation

@ramonskie

@ramonskie ramonskie commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the python-buildpack test suite from Ginkgo v1 to v2.

Commits

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.

Files changed: `go.mod`, `go.sum`, `vendor/`, all `*.go` source files with ginkgo imports.

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.

Files changed:

  • `src/python/supply/supply_test.go`
  • `src/python/conda/conda_test.go`
  • `src/python/finalize/finalize_test.go`
  • `src/python/hooks/appdynamics_test.go`
  • `src/python/hooks/hooks_test.go`
  • `src/python/hooks/sealights_test.go`
  • `src/python/pyfinder/manage_py_finder_test.go`
  • `src/python/requirements/requirements_test.go`

3. fix: install ginkgo v2 CLI and fix bare DeferCleanup in supply_test

`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`).

Also fixed a bare `DeferCleanup` in `supply_test.go` that was placed directly in a `Describe` body. Ginkgo v2 panics at runtime when `DeferCleanup` is called outside a setup or subject node. Wrapped in `BeforeEach`.

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.Info`, `Logger.Debug`, and `Logger.BeginStep`. 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 more `DeferCleanup` calls in `supply_test.go` were placed directly in `Describe` container bodies. Fixed by wrapping them in `BeforeEach`.

Files changed:

  • `src/python/finalize/finalize.go`
  • `src/python/hooks/appdynamics.go`
  • `src/python/hooks/hooks_app.go`
  • `src/python/hooks/sealights.go`
  • `src/python/supply/supply.go`
  • `src/python/supply/supply_test.go`

Verification

  • `./scripts/unit.sh` ✅
  • Zero `AfterEach` remaining in source (excluding vendor) ✅
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 to github.com/onsi/ginkgo/v2/ginkgo
- Wrap bare DeferCleanup in BeforeEach in HandlePylibmc Describe block;
  DeferCleanup must be called inside a setup node, not a container node.

@tnikolova82 tnikolova82 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tnikolova82
tnikolova82 merged commit db3c2b4 into master Mar 6, 2026
7 checks passed
@tnikolova82
tnikolova82 deleted the ginkgo-v2 branch March 6, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants