github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/offering/openshift/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 openshiftorderer_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  	openshiftorderer "github.com/IBM-Blockchain/fabric-operator/pkg/offering/openshift/orderer"
    29  	. "github.com/onsi/ginkgo/v2"
    30  	. "github.com/onsi/gomega"
    31  	"k8s.io/apimachinery/pkg/runtime"
    32  )
    33  
    34  var _ = Describe("Openshift Orderer", func() {
    35  	var (
    36  		orderer        *openshiftorderer.Orderer
    37  		instance       *current.IBPOrderer
    38  		mockKubeClient *cmocks.Client
    39  		cfg            *config.Config
    40  		update         *mocks.Update
    41  	)
    42  
    43  	Context("Reconciles", func() {
    44  		BeforeEach(func() {
    45  			precreate := false
    46  			mockKubeClient = &cmocks.Client{}
    47  			update = &mocks.Update{}
    48  			instance = &current.IBPOrderer{
    49  				Spec: current.IBPOrdererSpec{
    50  					License: current.License{
    51  						Accept: true,
    52  					},
    53  					OrdererType:       "etcdraft",
    54  					SystemChannelName: "testchainid",
    55  					OrgName:           "orderermsp",
    56  					MSPID:             "orderermsp",
    57  					ImagePullSecrets:  []string{"regcred"},
    58  					ClusterSecret:     []*current.SecretSpec{},
    59  					Secret:            &current.SecretSpec{},
    60  					IsPrecreate:       &precreate,
    61  					GenesisBlock:      "GenesisBlock",
    62  					Images:            &current.OrdererImages{},
    63  				},
    64  			}
    65  			instance.Kind = "IBPOrderer"
    66  
    67  			cfg = &config.Config{
    68  				OrdererInitConfig: &ordererinit.Config{
    69  					ConfigTxFile: "../../../../defaultconfig/orderer/configtx.yaml",
    70  					OUFile:       "../../../../defaultconfig/orderer/ouconfig.yaml",
    71  				},
    72  			}
    73  
    74  			orderer = &openshiftorderer.Orderer{
    75  				Orderer: &baseorderer.Orderer{
    76  					Client: mockKubeClient,
    77  					Scheme: &runtime.Scheme{},
    78  					Config: cfg,
    79  				},
    80  			}
    81  		})
    82  
    83  		PIt("reconciles openshift orderer", func() {
    84  			_, err := orderer.ReconcileNode(instance, update)
    85  			Expect(err).NotTo(HaveOccurred())
    86  		})
    87  	})
    88  })