mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-06-05 23:03:40 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user