sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/suite.go (about)

     1  /*
     2  Copyright 2022 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 e2e
    18  
    19  import (
    20  	"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
    21  )
    22  
    23  var _ machinery.Template = &SuiteTest{}
    24  
    25  type SuiteTest struct {
    26  	machinery.TemplateMixin
    27  	machinery.BoilerplateMixin
    28  	machinery.RepositoryMixin
    29  	machinery.ProjectNameMixin
    30  }
    31  
    32  func (f *SuiteTest) SetTemplateDefaults() error {
    33  	if f.Path == "" {
    34  		f.Path = "test/e2e/e2e_suite_test.go"
    35  	}
    36  
    37  	f.TemplateBody = suiteTestTemplate
    38  	return nil
    39  }
    40  
    41  var suiteTestTemplate = `{{ .Boilerplate }}
    42  
    43  package e2e
    44  
    45  import (
    46  	"fmt"
    47  	"testing"
    48  
    49  	. "github.com/onsi/ginkgo/v2"
    50  	. "github.com/onsi/gomega"
    51  )
    52  
    53  // Run e2e tests using the Ginkgo runner.
    54  func TestE2E(t *testing.T) {
    55  	RegisterFailHandler(Fail)
    56  	fmt.Fprintf(GinkgoWriter, "Starting {{ .ProjectName }} suite\n")
    57  	RunSpecs(t, "e2e suite")
    58  }
    59  `