github.com/terraform-modules-krish/terratest@v0.29.0/modules/k8s/namespace_test.go (about)

     1  // +build kubeall kubernetes
     2  
     3  // NOTE: we have build tags to differentiate kubernetes tests from non-kubernetes tests. This is done because minikube
     4  // is heavy and can interfere with docker related tests in terratest. Specifically, many of the tests start to fail with
     5  // `connection refused` errors from `minikube`. To avoid overloading the system, we run the kubernetes tests and helm
     6  // tests separately from the others. This may not be necessary if you have a sufficiently powerful machine.  We
     7  // recommend at least 4 cores and 16GB of RAM if you want to run all the tests together.
     8  
     9  package k8s
    10  
    11  import (
    12  	"strings"
    13  	"testing"
    14  
    15  	"github.com/stretchr/testify/require"
    16  	corev1 "k8s.io/api/core/v1"
    17  
    18  	"github.com/terraform-modules-krish/terratest/modules/random"
    19  )
    20  
    21  func TestNamespaces(t *testing.T) {
    22  	t.Parallel()
    23  
    24  	uniqueId := random.UniqueId()
    25  	namespaceName := strings.ToLower(uniqueId)
    26  	options := NewKubectlOptions("", "", namespaceName)
    27  	CreateNamespace(t, options, namespaceName)
    28  	defer func() {
    29  		DeleteNamespace(t, options, namespaceName)
    30  		namespace := GetNamespace(t, options, namespaceName)
    31  		require.Equal(t, namespace.Status.Phase, corev1.NamespaceTerminating)
    32  	}()
    33  
    34  	namespace := GetNamespace(t, options, namespaceName)
    35  	require.Equal(t, namespace.Name, namespaceName)
    36  }