github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/manager/resources/container/container_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 container_test 20 21 import ( 22 . "github.com/onsi/ginkgo/v2" 23 . "github.com/onsi/gomega" 24 25 "github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/container" 26 27 corev1 "k8s.io/api/core/v1" 28 ) 29 30 var _ = Describe("container", func() { 31 var ( 32 cont *container.Container 33 ) 34 35 BeforeEach(func() { 36 cont = &container.Container{ 37 Container: &corev1.Container{}, 38 } 39 }) 40 41 Context("env vars", func() { 42 BeforeEach(func() { 43 cont.Env = []corev1.EnvVar{ 44 corev1.EnvVar{ 45 Name: "env1", 46 Value: "1.0", 47 }, 48 } 49 50 Expect(cont.Env).To(ContainElement(corev1.EnvVar{Name: "env1", Value: "1.0"})) 51 }) 52 53 It("updates", func() { 54 cont.UpdateEnv("env1", "1.1") 55 Expect(len(cont.Env)).To(Equal(1)) 56 Expect(cont.Env).To(ContainElement(corev1.EnvVar{Name: "env1", Value: "1.1"})) 57 }) 58 }) 59 60 Context("set image", func() { 61 It("parses sha tags", func() { 62 cont.SetImage("ibp-peer", "sha256:12345") 63 Expect(cont.Image).To(Equal("ibp-peer@sha256:12345")) 64 }) 65 }) 66 })