mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-15 07:57:49 +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)
|
d := NewDiscovery(pool)
|
||||||
|
|
||||||
// This will either succeed or fail based on kubeconfig availability
|
// On CI without a kubeconfig, clientcmd returns an empty config with no
|
||||||
context, err := d.GetCurrentContext()
|
// 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 {
|
if err != nil {
|
||||||
// Expected if no kubeconfig
|
|
||||||
assert.Contains(t, err.Error(), "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