...

Source file src/sigs.k8s.io/controller-runtime/pkg/controller/controllerutil/controllerutil_suite_test.go

Documentation: sigs.k8s.io/controller-runtime/pkg/controller/controllerutil

     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 controllerutil_test
    18  
    19  import (
    20  	"testing"
    21  
    22  	. "github.com/onsi/ginkgo/v2"
    23  	. "github.com/onsi/gomega"
    24  
    25  	"k8s.io/client-go/rest"
    26  	"sigs.k8s.io/controller-runtime/pkg/client"
    27  	"sigs.k8s.io/controller-runtime/pkg/envtest"
    28  )
    29  
    30  func TestControllerutil(t *testing.T) {
    31  	RegisterFailHandler(Fail)
    32  	RunSpecs(t, "Controllerutil Suite")
    33  }
    34  
    35  var testenv *envtest.Environment
    36  var cfg *rest.Config
    37  var c client.Client
    38  
    39  var _ = BeforeSuite(func() {
    40  	var err error
    41  
    42  	testenv = &envtest.Environment{}
    43  
    44  	cfg, err = testenv.Start()
    45  	Expect(err).NotTo(HaveOccurred())
    46  
    47  	c, err = client.New(cfg, client.Options{})
    48  	Expect(err).NotTo(HaveOccurred())
    49  })
    50  
    51  var _ = AfterSuite(func() {
    52  	Expect(testenv.Stop()).To(Succeed())
    53  })
    54  

View as plain text