sigs.k8s.io/cluster-api-provider-azure@v1.14.3/azure/converters/dns_test.go (about)

     1  /*
     2  Copyright 2019 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 converters
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns"
    23  	"github.com/onsi/gomega"
    24  )
    25  
    26  func Test_GetRecordType(t *testing.T) {
    27  	cases := []struct {
    28  		name   string
    29  		ip     string
    30  		expect armprivatedns.RecordType
    31  	}{
    32  		{
    33  			name:   "ipv4",
    34  			ip:     "10.0.0.4",
    35  			expect: armprivatedns.RecordTypeA,
    36  		},
    37  		{
    38  			name:   "ipv6",
    39  			ip:     "2603:1030:805:2::b",
    40  			expect: armprivatedns.RecordTypeAAAA,
    41  		},
    42  		{
    43  			name:   "default",
    44  			ip:     "",
    45  			expect: armprivatedns.RecordTypeA,
    46  		},
    47  	}
    48  
    49  	for _, c := range cases {
    50  		c := c
    51  		t.Run(c.name, func(t *testing.T) {
    52  			t.Parallel()
    53  			g := gomega.NewGomegaWithT(t)
    54  			recordType := GetRecordType(c.ip)
    55  			g.Expect(c.expect).To(gomega.BeEquivalentTo(recordType))
    56  		})
    57  	}
    58  }