github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/clients/fake/fake_factory_test.go (about)

     1  // +build unit
     2  
     3  package fake
     4  
     5  import (
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  	"github.com/stretchr/testify/require"
    10  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    11  )
    12  
    13  func TestFakeFactory(t *testing.T) {
    14  	f := NewFakeFactory()
    15  	client, ns, err := f.CreateKubeClient()
    16  	require.NoError(t, err, "CreateKubeClient() failed")
    17  	assert.Equal(t, "jx", ns, "namespace")
    18  	assert.NotNil(t, client, "client")
    19  
    20  	namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{})
    21  	require.NoError(t, err, "Namespaces().List() failed")
    22  	require.NotNil(t, namespaces, "namespaces")
    23  	assert.Equal(t, 0, len(namespaces.Items), "namespaces")
    24  
    25  }