github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/pkg/resources/statefulsets/pvc_test.go (about)

     1  // Copyright (C) 2022, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package statefulsets
     5  
     6  import (
     7  	"github.com/stretchr/testify/assert"
     8  	corev1 "k8s.io/api/core/v1"
     9  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    10  	"testing"
    11  )
    12  
    13  func TestGetPVCNames(t *testing.T) {
    14  	sts := createTestSTS("foo", 2)
    15  	sts.Spec.VolumeClaimTemplates = []corev1.PersistentVolumeClaim{
    16  		{
    17  			ObjectMeta: metav1.ObjectMeta{
    18  				Name: "p1",
    19  			},
    20  		},
    21  	}
    22  
    23  	pvcNames := GetPVCNames(sts)
    24  	assert.Equal(t, 2, len(pvcNames))
    25  	assert.Equal(t, "p1-foo-0", pvcNames[0])
    26  	assert.Equal(t, "p1-foo-1", pvcNames[1])
    27  }