@@ -152,6 +152,32 @@ func TestNewCloud(t *testing.T) {
152152 require .Error (t , err , "expected error if nodebalancer-prefix is longer than 19 chars" )
153153 require .ErrorContains (t , err , "nodebalancer-prefix" )
154154 })
155+
156+ t .Run ("should fail if nodebalancer-prefix is empty" , func (t * testing.T ) {
157+ prefix := Options .NodeBalancerPrefix
158+ rtEnabled := Options .EnableRouteController
159+ Options .EnableRouteController = false
160+ Options .LoadBalancerType = "nodebalancer"
161+ Options .VPCNames = "vpc-test1,vpc-test2"
162+ Options .NodeBalancerBackendIPv4SubnetName = "t1"
163+ vpcIDs = map [string ]int {"vpc-test1" : 1 , "vpc-test2" : 2 , "vpc-test3" : 3 }
164+ subnetIDs = map [string ]int {"t1" : 1 , "t2" : 2 , "t3" : 3 }
165+ Options .NodeBalancerPrefix = strings .Repeat ("a" , 21 )
166+ defer func () {
167+ Options .NodeBalancerPrefix = prefix
168+ Options .LoadBalancerType = ""
169+ Options .EnableRouteController = rtEnabled
170+ Options .VPCNames = ""
171+ Options .NodeBalancerBackendIPv4SubnetID = 0
172+ Options .NodeBalancerBackendIPv4SubnetName = ""
173+ vpcIDs = map [string ]int {}
174+ subnetIDs = map [string ]int {}
175+ }()
176+ _ , err := newCloud ()
177+ t .Log (err )
178+ require .Error (t , err , "expected error if nodebalancer-prefix is empty" )
179+ require .ErrorContains (t , err , "nodebalancer-prefix cannot be empty" )
180+ })
155181}
156182
157183func Test_linodeCloud_LoadBalancer (t * testing.T ) {
0 commit comments