Skip to content

Commit

Permalink
Merge pull request vmware#1992 from jmpfar/issue-1991
Browse files Browse the repository at this point in the history
vcsim: CreateSnapshotTask now returns moref in result
  • Loading branch information
dougm authored May 26, 2020
2 parents 61b30e2 + c3fe4f8 commit 776bf25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion simulator/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ func (vm *VirtualMachine) CreateSnapshotTask(req *types.CreateSnapshot_Task) soa
changes = append(changes, types.PropertyChange{Name: "snapshot.currentSnapshot", Val: snapshot.Self})
Map.Update(vm, changes)

return nil, nil
return snapshot.Self, nil
})

return &methods.CreateSnapshot_TaskBody{
Expand Down
12 changes: 11 additions & 1 deletion simulator/virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,11 +773,21 @@ func TestVmSnapshot(t *testing.T) {
t.Fatal(err)
}

err = task.Wait(ctx)
info, err := task.WaitForResult(ctx)
if err != nil {
t.Fatal(err)
}

snapRef, ok := info.Result.(types.ManagedObjectReference)
if !ok {
t.Fatal("expected ManagedObjectRefrence result for CreateSnapshot")
}

_, err = vm.FindSnapshot(ctx, snapRef.Value)
if err != nil {
t.Fatal(err, "snapshot should be found by result reference")
}

_, err = fieldValue(reflect.ValueOf(simVm), "snapshot")
if err == errEmptyField {
t.Fatal("snapshot property should not be 'nil' if there are snapshots")
Expand Down

0 comments on commit 776bf25

Please sign in to comment.