github.com/verrazzano/verrazzano@v1.7.0/cluster-operator/controllers/quickcreate/ociocne/properties_test.go (about)

     1  // Copyright (c) 2023, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package ociocne
     5  
     6  import (
     7  	"context"
     8  	_ "embed"
     9  	"github.com/stretchr/testify/assert"
    10  	"sigs.k8s.io/controller-runtime/pkg/client/fake"
    11  	"testing"
    12  )
    13  
    14  func TestCreateAndApplyOCNETemplate(t *testing.T) {
    15  	var tests = []struct {
    16  		name  string
    17  		patch []byte
    18  	}{
    19  		{
    20  			"existing vcn",
    21  			testExistingVCNPatch,
    22  		},
    23  		{
    24  			"new vcn",
    25  			testNewVCNPatch,
    26  		},
    27  	}
    28  
    29  	cli := fake.NewClientBuilder().WithScheme(scheme).WithObjects(testOCNEConfigMap()).Build()
    30  
    31  	for _, tt := range tests {
    32  		t.Run(tt.name, func(t *testing.T) {
    33  			q, err := testCreateCR(tt.patch)
    34  			assert.NoError(t, err)
    35  			ctx := context.TODO()
    36  			p, err := NewProperties(ctx, cli, testLoader, testOCIClientGetter, q)
    37  			assert.NoError(t, err)
    38  			assert.NotNil(t, p)
    39  			err = p.ApplyTemplate(cli, clusterTemplate, nodesTemplate, ocneTemplate, addonsTemplate)
    40  			assert.NoError(t, err)
    41  		})
    42  	}
    43  }