From dea3273eaf692d951d579263a928caf6c6324808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 3 Feb 2021 08:56:41 +0100 Subject: [PATCH] ceph: do not force go path in unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not force unit tests to be run while the rook repo is in the GOPATH. Now that Rook uses go modules, this is no longer necessary. Allow this by creating a helper function that unit tests can use that return the on-host path to the `rook` project root. Followup of https://github.com/rook/rook/pull/7119/commits/15a487cd5aa5d4dc59bc15ef610cb182257d9287 Signed-off-by: Sébastien Han --- pkg/operator/k8sutil/prometheus_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/operator/k8sutil/prometheus_test.go b/pkg/operator/k8sutil/prometheus_test.go index ef6fa8e69..db9ad42cb 100644 --- a/pkg/operator/k8sutil/prometheus_test.go +++ b/pkg/operator/k8sutil/prometheus_test.go @@ -18,7 +18,6 @@ limitations under the License. package k8sutil import ( - "os" "path" "testing" @@ -38,8 +37,8 @@ func TestGetServiceMonitor(t *testing.T) { } func TestGetPrometheusRule(t *testing.T) { - gopath := os.Getenv("GOPATH") - filePath := path.Join(gopath, "src/github.com/rook/rook/cluster/examples/kubernetes/ceph/monitoring/prometheus-ceph-v14-rules.yaml") + projectRoot := util.PathToProjectRoot() + filePath := path.Join(projectRoot, "/cluster/examples/kubernetes/ceph/monitoring/prometheus-ceph-v14-rules.yaml") rules, err := GetPrometheusRule(filePath) assert.Nil(t, err) assert.Equal(t, "prometheus-ceph-rules", rules.GetName())