sigs.k8s.io/controller-runtime@v0.18.2/pkg/internal/recorder/recorder_suite_test.go (about) 1 /* 2 Copyright 2018 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package recorder_test 18 19 import ( 20 "net/http" 21 "testing" 22 23 . "github.com/onsi/ginkgo/v2" 24 . "github.com/onsi/gomega" 25 "k8s.io/client-go/kubernetes" 26 "k8s.io/client-go/rest" 27 "sigs.k8s.io/controller-runtime/pkg/envtest" 28 logf "sigs.k8s.io/controller-runtime/pkg/log" 29 "sigs.k8s.io/controller-runtime/pkg/log/zap" 30 ) 31 32 func TestRecorder(t *testing.T) { 33 RegisterFailHandler(Fail) 34 RunSpecs(t, "Recorder Integration Suite") 35 } 36 37 var testenv *envtest.Environment 38 var cfg *rest.Config 39 var httpClient *http.Client 40 var clientset *kubernetes.Clientset 41 42 var _ = BeforeSuite(func() { 43 logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) 44 45 testenv = &envtest.Environment{} 46 47 var err error 48 cfg, err = testenv.Start() 49 Expect(err).NotTo(HaveOccurred()) 50 51 httpClient, err = rest.HTTPClientFor(cfg) 52 Expect(err).ToNot(HaveOccurred()) 53 54 clientset, err = kubernetes.NewForConfig(cfg) 55 Expect(err).NotTo(HaveOccurred()) 56 }) 57 58 var _ = AfterSuite(func() { 59 Expect(testenv.Stop()).To(Succeed()) 60 })