MCPcopy
hub / github.com/kubernetes/client-go / TestCreateMissingContext

Function TestCreateMissingContext

tools/clientcmd/client_config_test.go:471–485  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

469}
470
471func TestCreateMissingContext(t *testing.T) {
472 const expectedErrorContains = "context was not found for specified context: not-present"
473 config := createValidTestConfig()
474 clientBuilder := NewNonInteractiveClientConfig(*config, "not-present", &ConfigOverrides{
475 ClusterDefaults: clientcmdapi.Cluster{Server: "http://localhost:8080"},
476 }, nil)
477
478 _, err := clientBuilder.ClientConfig()
479 if err == nil {
480 t.Fatalf("Expected error: %v", expectedErrorContains)
481 }
482 if !strings.Contains(err.Error(), expectedErrorContains) {
483 t.Fatalf("Expected error: %v, but got %v", expectedErrorContains, err)
484 }
485}
486
487func TestInClusterClientConfigPrecedence(t *testing.T) {
488 tt := []struct {

Callers

nothing calls this directly

Calls 4

createValidTestConfigFunction · 0.85
ClientConfigMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected