github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/offering/k8s/orderer/orderer_test.go (about)

     1  /*
     2   * Copyright contributors to the Hyperledger Fabric Operator project
     3   *
     4   * SPDX-License-Identifier: Apache-2.0
     5   *
     6   * Licensed under the Apache License, Version 2.0 (the "License");
     7   * you may not use this file except in compliance with the License.
     8   * You may obtain a copy of the License at:
     9   *
    10   * 	  http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   * Unless required by applicable law or agreed to in writing, software
    13   * distributed under the License is distributed on an "AS IS" BASIS,
    14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15   * See the License for the specific language governing permissions and
    16   * limitations under the License.
    17   */
    18  
    19  package k8sorderer_test
    20  
    21  import (
    22  	current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
    23  	cmocks "github.com/IBM-Blockchain/fabric-operator/controllers/mocks"
    24  	config "github.com/IBM-Blockchain/fabric-operator/operatorconfig"
    25  	ordererinit "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/orderer"
    26  	baseorderer "github.com/IBM-Blockchain/fabric-operator/pkg/offering/base/orderer"
    27  	"github.com/IBM-Blockchain/fabric-operator/pkg/offering/base/orderer/mocks"
    28  	k8sorderer "github.com/IBM-Blockchain/fabric-operator/pkg/offering/k8s/orderer"
    29  	. "github.com/onsi/ginkgo/v2"
    30  	. "github.com/onsi/gomega"
    31  	"k8s.io/apimachinery/pkg/runtime"
    32  )
    33  
    34  var _ = Describe("K8S Orderer", func() {
    35  	var (
    36  		orderer        *k8sorderer.Orderer
    37  		instance       *current.IBPOrderer
    38  		mockKubeClient *cmocks.Client
    39  		cfg            *config.Config
    40  		update         *mocks.Update
    41  	)
    42  
    43  	BeforeEach(func() {
    44  		mockKubeClient = &cmocks.Client{}
    45  		update = &mocks.Update{}
    46  		instance = &current.IBPOrderer{
    47  			Spec: current.IBPOrdererSpec{
    48  				License: current.License{
    49  					Accept: true,
    50  				},
    51  				OrdererType:       "etcdraft",
    52  				SystemChannelName: "testchainid",
    53  				OrgName:           "orderermsp",
    54  				MSPID:             "orderermsp",
    55  				ImagePullSecrets:  []string{"regcred"},
    56  				ClusterSecret:     []*current.SecretSpec{},
    57  				Secret:            &current.SecretSpec{},
    58  				GenesisBlock:      "GenesisBlock",
    59  				Images:            &current.OrdererImages{},
    60  			},
    61  		}
    62  		instance.Kind = "IBPOrderer"
    63  
    64  		cfg = &config.Config{
    65  			OrdererInitConfig: &ordererinit.Config{
    66  				ConfigTxFile: "../../../../defaultconfig/orderer/configtx.yaml",
    67  				OUFile:       "../../../../defaultconfig/orderer/ouconfig.yaml",
    68  			},
    69  		}
    70  
    71  		orderer = &k8sorderer.Orderer{
    72  			Orderer: &baseorderer.Orderer{
    73  				Client: mockKubeClient,
    74  				Scheme: &runtime.Scheme{},
    75  				Config: cfg,
    76  			},
    77  		}
    78  	})
    79  
    80  	Context("Reconciles", func() {
    81  		It("reconciles IBPOrderer", func() {
    82  			_, err := orderer.Reconcile(instance, update)
    83  			Expect(err).NotTo(HaveOccurred())
    84  		})
    85  	})
    86  })