github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/testing/fake_test.go (about)

     1  /*
     2  Copyright (C) 2022-2023 ApeCloud Co., Ltd
     3  
     4  This file is part of KubeBlocks project
     5  
     6  This program is free software: you can redistribute it and/or modify
     7  it under the terms of the GNU Affero General Public License as published by
     8  the Free Software Foundation, either version 3 of the License, or
     9  (at your option) any later version.
    10  
    11  This program is distributed in the hope that it will be useful
    12  but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  GNU Affero General Public License for more details.
    15  
    16  You should have received a copy of the GNU Affero General Public License
    17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  */
    19  
    20  package testing
    21  
    22  import (
    23  	. "github.com/onsi/ginkgo/v2"
    24  	. "github.com/onsi/gomega"
    25  )
    26  
    27  var _ = Describe("test fake", func() {
    28  	It("cluster", func() {
    29  		cluster := FakeCluster(ClusterName, Namespace)
    30  		Expect(cluster).ShouldNot(BeNil())
    31  		Expect(cluster.Name).Should(Equal(ClusterName))
    32  	})
    33  
    34  	It("cluster definition", func() {
    35  		clusterDef := FakeClusterDef()
    36  		Expect(clusterDef).ShouldNot(BeNil())
    37  		Expect(clusterDef.Name).Should(Equal(ClusterDefName))
    38  	})
    39  
    40  	It("cluster definition", func() {
    41  		clusterVersion := FakeClusterVersion()
    42  		Expect(clusterVersion).ShouldNot(BeNil())
    43  		Expect(clusterVersion.Name).Should(Equal(ClusterVersionName))
    44  	})
    45  
    46  	It("pods", func() {
    47  		pods := FakePods(3, Namespace, ClusterName)
    48  		Expect(pods).ShouldNot(BeNil())
    49  		Expect(len(pods.Items)).Should(Equal(3))
    50  	})
    51  
    52  	It("secrets", func() {
    53  		secrets := FakeSecrets(Namespace, ClusterName)
    54  		Expect(secrets).ShouldNot(BeNil())
    55  		Expect(len(secrets.Items)).Should(Equal(1))
    56  	})
    57  
    58  	It("services", func() {
    59  		svcs := FakeServices()
    60  		Expect(svcs).ShouldNot(BeNil())
    61  		Expect(len(svcs.Items)).Should(Equal(4))
    62  	})
    63  
    64  	It("node", func() {
    65  		node := FakeNode()
    66  		Expect(node).ShouldNot(BeNil())
    67  		Expect(node.Name).Should(Equal(NodeName))
    68  	})
    69  
    70  	It("fake client set", func() {
    71  		client := FakeClientSet()
    72  		Expect(client).ShouldNot(BeNil())
    73  	})
    74  
    75  	It("fake dynamic set", func() {
    76  		dynamic := FakeDynamicClient()
    77  		Expect(dynamic).ShouldNot(BeNil())
    78  	})
    79  
    80  	It("fake PVCs", func() {
    81  		pvcs := FakePVCs()
    82  		Expect(pvcs).ShouldNot(BeNil())
    83  	})
    84  
    85  	It("fake events", func() {
    86  		events := FakeEvents()
    87  		Expect(events).ShouldNot(BeNil())
    88  	})
    89  
    90  	It("fake storageClass", func() {
    91  		StorageClassDefault := FakeStorageClass(StorageClassName, IsDefault)
    92  		Expect(StorageClassDefault).ShouldNot(BeNil())
    93  		StorageClassNotDefault := FakeStorageClass(StorageClassName, IsDefault)
    94  		Expect(StorageClassNotDefault).ShouldNot(BeNil())
    95  	})
    96  })