github.com/vmware/govmomi@v0.51.0/task/wait_test.go (about)

     1  // © Broadcom. All Rights Reserved.
     2  // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package task
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/vmware/govmomi/vim25/mo"
    11  	"github.com/vmware/govmomi/vim25/types"
    12  )
    13  
    14  // ensure task.Manager implements the mo.Reference interface
    15  var _ mo.Reference = new(Manager)
    16  
    17  func TestCallbackFn(t *testing.T) {
    18  	cb := &taskCallback{}
    19  
    20  	for _, o := range []types.PropertyChangeOp{types.PropertyChangeOpAdd, types.PropertyChangeOpRemove, types.PropertyChangeOpAssign, types.PropertyChangeOpIndirectRemove} {
    21  		for _, s := range []types.TaskInfoState{types.TaskInfoStateQueued, types.TaskInfoStateRunning, types.TaskInfoStateSuccess, types.TaskInfoStateError} {
    22  			c := types.PropertyChange{
    23  				Name: "info",
    24  				Op:   o,
    25  				Val: types.TaskInfo{
    26  					State: s,
    27  				},
    28  			}
    29  			t.Logf("Op: %s State: %s", o, s)
    30  			cb.fn([]types.PropertyChange{c})
    31  		}
    32  	}
    33  }