From 614b6e6396f9695c2d574a523d5918340ff86422 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Wed, 6 May 2026 10:34:46 +0100 Subject: [PATCH] test: relax TestDiscovery_GetCurrentContext for empty kubeconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI runners have no kubeconfig, so clientcmd's loader returns an empty config (no error) and CurrentContext == "". The previous assertion 'NotEmpty(context)' on the success branch was incorrect — an empty current-context is valid for an empty kubeconfig. Mirrors the looser pattern in TestDiscovery_ListContexts. --- internal/k8s/k8s_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/k8s/k8s_test.go b/internal/k8s/k8s_test.go index 059836c..a1a6252 100644 --- a/internal/k8s/k8s_test.go +++ b/internal/k8s/k8s_test.go @@ -919,14 +919,11 @@ func TestDiscovery_GetCurrentContext(t *testing.T) { d := NewDiscovery(pool) - // This will either succeed or fail based on kubeconfig availability - context, err := d.GetCurrentContext() - + // On CI without a kubeconfig, clientcmd returns an empty config with no + // error and CurrentContext == "". On a dev box with a real kubeconfig, + // CurrentContext is whatever the user has set. Either is valid. + _, err = d.GetCurrentContext() if err != nil { - // Expected if no kubeconfig assert.Contains(t, err.Error(), "kubeconfig") - } else { - // If successful, should be a string - assert.NotEmpty(t, context) } }