@@ -18,8 +18,6 @@ package ingress_test
1818
1919import (
2020 "context"
21- "os"
22- "path/filepath"
2321 "testing"
2422
2523 . "github.com/onsi/ginkgo/v2"
@@ -58,15 +56,7 @@ var _ = BeforeSuite(func() {
5856 var err error
5957
6058 By ("bootstrapping test environment" )
61- testEnv = & envtest.Environment {
62- CRDDirectoryPaths : []string {filepath .Join (".." , ".." , "config" , "crd" , "bases" )},
63- ErrorIfCRDPathMissing : false ,
64- }
65-
66- // Retrieve the first found binary directory to allow running tests from IDEs
67- if getFirstFoundEnvTestBinaryDir () != "" {
68- testEnv .BinaryAssetsDirectory = getFirstFoundEnvTestBinaryDir ()
69- }
59+ testEnv = & envtest.Environment {}
7060
7161 // cfg is defined in this file globally.
7262 cfg , err = testEnv .Start ()
@@ -84,26 +74,3 @@ var _ = AfterSuite(func() {
8474 err := testEnv .Stop ()
8575 Expect (err ).NotTo (HaveOccurred ())
8676})
87-
88- // getFirstFoundEnvTestBinaryDir locates the first binary in the specified path.
89- // ENVTEST-based tests depend on specific binaries, usually located in paths set by
90- // controller-runtime. When running tests directly (e.g., via an IDE) without using
91- // Makefile targets, the 'BinaryAssetsDirectory' must be explicitly configured.
92- //
93- // This function streamlines the process by finding the required binaries, similar to
94- // setting the 'KUBEBUILDER_ASSETS' environment variable. To ensure the binaries are
95- // properly set up, run 'make setup-envtest' beforehand.
96- func getFirstFoundEnvTestBinaryDir () string {
97- basePath := filepath .Join (".." , ".." , "bin" , "k8s" )
98- entries , err := os .ReadDir (basePath )
99- if err != nil {
100- logf .Log .Error (err , "Failed to read directory" , "path" , basePath )
101- return ""
102- }
103- for _ , entry := range entries {
104- if entry .IsDir () {
105- return filepath .Join (basePath , entry .Name ())
106- }
107- }
108- return ""
109- }
0 commit comments