github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/offering/base/orderer/override/service_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 override_test
    20  
    21  import (
    22  	. "github.com/onsi/ginkgo/v2"
    23  	. "github.com/onsi/gomega"
    24  	corev1 "k8s.io/api/core/v1"
    25  
    26  	current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1"
    27  	"github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources"
    28  	"github.com/IBM-Blockchain/fabric-operator/pkg/offering/base/orderer/override"
    29  	"github.com/IBM-Blockchain/fabric-operator/pkg/util"
    30  )
    31  
    32  var _ = Describe("Base Orderer Service Overrides", func() {
    33  	var (
    34  		overrider *override.Override
    35  		instance  *current.IBPOrderer
    36  		service   *corev1.Service
    37  	)
    38  
    39  	BeforeEach(func() {
    40  		var err error
    41  
    42  		service, err = util.GetServiceFromFile("../../../../../definitions/orderer/service.yaml")
    43  		Expect(err).NotTo(HaveOccurred())
    44  
    45  		overrider = &override.Override{}
    46  		instance = &current.IBPOrderer{
    47  			Spec: current.IBPOrdererSpec{
    48  				Service: &current.Service{
    49  					Type: corev1.ServiceTypeNodePort,
    50  				},
    51  			},
    52  		}
    53  	})
    54  
    55  	Context("create", func() {
    56  		It("overrides values based on spec", func() {
    57  			err := overrider.Service(instance, service, resources.Create)
    58  			Expect(err).NotTo(HaveOccurred())
    59  
    60  			By("setting service type", func() {
    61  				Expect(service.Spec.Type).To(Equal(instance.Spec.Service.Type))
    62  			})
    63  		})
    64  	})
    65  })