github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/test_utils.go (about)

     1  package internal
     2  
     3  import (
     4  	"embed"
     5  	"fmt"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  	corev1 "k8s.io/api/core/v1"
    10  	apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
    11  	"k8s.io/apimachinery/pkg/runtime"
    12  )
    13  
    14  // KEB tests can run in parallel resulting in concurrent access to scheme maps
    15  // if the global scheme from client-go is used. For this reason, KEB tests each have
    16  // their own scheme.
    17  func NewSchemeForTests() *runtime.Scheme {
    18  	sch := runtime.NewScheme()
    19  	corev1.AddToScheme(sch)
    20  	apiextensionsv1.AddToScheme(sch)
    21  	return sch
    22  }
    23  
    24  //go:embed testdata/kymatemplate
    25  var content embed.FS
    26  
    27  func GetKymaTemplateForTests(t *testing.T, path string) string {
    28  	file, err := content.ReadFile(fmt.Sprintf("%s/%s/%s", "testdata", "kymatemplate", path))
    29  	assert.NoError(t, err)
    30  	return string(file)
    31  }