@@ -3412,16 +3412,17 @@ func Test_GetLoadBalancer(t *testing.T) {
34123412
34133413func Test_EnsureLoadBalancer (t * testing.T ) {
34143414 testcases := []struct {
3415- name string
3416- droplets []godo.Droplet
3417- getFn func (context.Context , string ) (* godo.LoadBalancer , * godo.Response , error )
3418- listFn func (context.Context , * godo.ListOptions ) ([]godo.LoadBalancer , * godo.Response , error )
3419- createFn func (context.Context , * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error )
3420- updateFn func (ctx context.Context , lbID string , lbr * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error )
3421- service * v1.Service
3422- nodes []* v1.Node
3423- lbStatus * v1.LoadBalancerStatus
3424- err error
3415+ name string
3416+ droplets []godo.Droplet
3417+ getFn func (context.Context , string ) (* godo.LoadBalancer , * godo.Response , error )
3418+ listFn func (context.Context , * godo.ListOptions ) ([]godo.LoadBalancer , * godo.Response , error )
3419+ createFn func (context.Context , * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error )
3420+ updateFn func (ctx context.Context , lbID string , lbr * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error )
3421+ service * v1.Service
3422+ newLoadBalancerID string
3423+ nodes []* v1.Node
3424+ lbStatus * v1.LoadBalancerStatus
3425+ err error
34253426 }{
34263427 {
34273428 name : "successfully ensured loadbalancer by name, already exists" ,
@@ -3666,7 +3667,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
36663667 return nil , newFakeNotOKResponse (), errors .New ("list should not have been invoked" )
36673668 },
36683669 createFn : func (context.Context , * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error ) {
3669- return createLB (), newFakeOKResponse (), nil
3670+ lb := createLB ()
3671+ lb .ID = "other-load-balancer-id"
3672+ return lb , newFakeOKResponse (), nil
36703673 },
36713674 updateFn : func (ctx context.Context , lbID string , lbr * godo.LoadBalancerRequest ) (* godo.LoadBalancer , * godo.Response , error ) {
36723675 return nil , newFakeNotOKResponse (), errors .New ("update should not have been invoked" )
@@ -3691,6 +3694,7 @@ func Test_EnsureLoadBalancer(t *testing.T) {
36913694 },
36923695 },
36933696 },
3697+ newLoadBalancerID : "other-load-balancer-id" ,
36943698 nodes : []* v1.Node {
36953699 {
36963700 ObjectMeta : metav1.ObjectMeta {
@@ -3821,6 +3825,9 @@ func Test_EnsureLoadBalancer(t *testing.T) {
38213825
38223826 gotLoadBalancerID := svc .Annotations [annoDOLoadBalancerID ]
38233827 wantLoadBalancerID := "load-balancer-id"
3828+ if test .newLoadBalancerID != "" {
3829+ wantLoadBalancerID = test .newLoadBalancerID
3830+ }
38243831 if gotLoadBalancerID != wantLoadBalancerID {
38253832 t .Errorf ("got load-balancer ID %q, want %q" , gotLoadBalancerID , wantLoadBalancerID )
38263833 }
0 commit comments