@@ -20,6 +20,7 @@ import (
2020 "testing"
2121
2222 . "github.com/onsi/gomega"
23+ corev1 "k8s.io/api/core/v1"
2324)
2425
2526var (
@@ -37,17 +38,17 @@ func TestVSphereVM_ValidateCreate(t *testing.T) {
3738 }{
3839 {
3940 name : "preferredAPIServerCIDR set on creation " ,
40- vSphereVM : createVSphereVM ("foo.com" , "" , "192.168.0.1/32" , []string {}),
41+ vSphereVM : createVSphereVM ("foo.com" , "" , "192.168.0.1/32" , []string {}, nil ),
4142 wantErr : true ,
4243 },
4344 {
4445 name : "IPs are not in CIDR format" ,
45- vSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" , "192.168.0.3" }),
46+ vSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" , "192.168.0.3" }, nil ),
4647 wantErr : true ,
4748 },
4849 {
4950 name : "successful VSphereVM creation" ,
50- vSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" , "192.168.0.3/32" }),
51+ vSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" , "192.168.0.3/32" }, nil ),
5152 wantErr : false ,
5253 },
5354 }
@@ -76,20 +77,26 @@ func TestVSphereVM_ValidateUpdate(t *testing.T) {
7677 }{
7778 {
7879 name : "ProviderID can be updated" ,
79- oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }),
80- vSphereVM : createVSphereVM ("foo.com" , biosUUID , "" , []string {"192.168.0.1/32" }),
80+ oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }, nil ),
81+ vSphereVM : createVSphereVM ("foo.com" , biosUUID , "" , []string {"192.168.0.1/32" }, nil ),
8182 wantErr : false ,
8283 },
8384 {
8485 name : "updating ips can be done" ,
85- oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }),
86- vSphereVM : createVSphereVM ("foo.com" , biosUUID , "" , []string {"192.168.0.1/32" , "192.168.0.10/32" }),
86+ oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }, nil ),
87+ vSphereVM : createVSphereVM ("foo.com" , biosUUID , "" , []string {"192.168.0.1/32" , "192.168.0.10/32" }, nil ),
88+ wantErr : false ,
89+ },
90+ {
91+ name : "updating bootstrapRef can be done" ,
92+ oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }, nil ),
93+ vSphereVM : createVSphereVM ("foo.com" , biosUUID , "" , []string {"192.168.0.1/32" , "192.168.0.10/32" }, & corev1.ObjectReference {}),
8794 wantErr : false ,
8895 },
8996 {
9097 name : "updating server cannot be done" ,
91- oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }),
92- vSphereVM : createVSphereVM ("bar.com" , biosUUID , "" , []string {"192.168.0.1/32" , "192.168.0.10/32" }),
98+ oldVSphereVM : createVSphereVM ("foo.com" , "" , "" , []string {"192.168.0.1/32" }, nil ),
99+ vSphereVM : createVSphereVM ("bar.com" , biosUUID , "" , []string {"192.168.0.1/32" , "192.168.0.10/32" }, nil ),
93100 wantErr : true ,
94101 },
95102 }
@@ -105,10 +112,11 @@ func TestVSphereVM_ValidateUpdate(t *testing.T) {
105112 }
106113}
107114
108- func createVSphereVM (server string , biosUUID string , preferredAPIServerCIDR string , ips []string ) * VSphereVM {
115+ func createVSphereVM (server string , biosUUID string , preferredAPIServerCIDR string , ips []string , bootstrapRef * corev1. ObjectReference ) * VSphereVM {
109116 VSphereVM := & VSphereVM {
110117 Spec : VSphereVMSpec {
111- BiosUUID : biosUUID ,
118+ BiosUUID : biosUUID ,
119+ BootstrapRef : bootstrapRef ,
112120 VirtualMachineCloneSpec : VirtualMachineCloneSpec {
113121 Server : server ,
114122 Network : NetworkSpec {
0 commit comments