github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/openstack/validate_test.go (about)

     1  package openstack
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  	"k8s.io/utils/pointer"
     8  
     9  	"github.com/openshift/installer/pkg/types"
    10  )
    11  
    12  func TestValidateForProvisioning(t *testing.T) {
    13  	cases := []struct {
    14  		name           string
    15  		installConfig  *types.InstallConfig
    16  		expectedErrMsg string
    17  	}{
    18  		{
    19  			name: "three-node control plane",
    20  			installConfig: &types.InstallConfig{
    21  				ControlPlane: &types.MachinePool{
    22  					Replicas: pointer.Int64Ptr(3),
    23  				},
    24  			},
    25  			expectedErrMsg: "",
    26  		}, {
    27  			name: "five-node control plane",
    28  			installConfig: &types.InstallConfig{
    29  				ControlPlane: &types.MachinePool{
    30  					Replicas: pointer.Int64Ptr(5),
    31  				},
    32  			},
    33  			expectedErrMsg: `controlPlane.replicas: Invalid value: 5: control plane cannot be more than three nodes when provisioning on OpenStack`,
    34  		},
    35  	}
    36  	for _, tc := range cases {
    37  		t.Run(tc.name, func(t *testing.T) {
    38  			err := ValidateForProvisioning(tc.installConfig)
    39  			if tc.expectedErrMsg == "" {
    40  				assert.NoError(t, err)
    41  			} else {
    42  				assert.Regexp(t, tc.expectedErrMsg, err)
    43  			}
    44  		})
    45  	}
    46  }