test: relax TestDiscovery_GetCurrentContext for empty kubeconfig

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.
This commit is contained in:
2026-05-06 10:34:46 +01:00
parent 8e5eaab0af
commit 614b6e6396
+4 -7
View File
@@ -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)
}
}