Skip to content

Commit

Permalink
vcsim: Fix RefreshDatastore to return a valid response
Browse files Browse the repository at this point in the history
Closes: #3198
  • Loading branch information
dekp authored and dougm committed Aug 3, 2023
1 parent fe7a0ac commit 3dac2e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion simulator/datastore.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2023 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,6 +83,7 @@ func (ds *Datastore) RefreshDatastore(*types.RefreshDatastore) soap.HasFault {

info.Timestamp = types.NewTime(time.Now())

r.Res = &types.RefreshDatastoreResponse{}
return r
}

Expand Down
13 changes: 11 additions & 2 deletions simulator/datastore_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2017 VMware, Inc. All Rights Reserved.
Copyright (c) 2017-2023 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,7 @@ import (
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25/types"
)
Expand Down Expand Up @@ -85,7 +86,12 @@ func TestRefreshDatastore(t *testing.T) {
},
}

res := ds.RefreshDatastore(nil)
r := ds.RefreshDatastore(nil)
res, ok := r.(*methods.RefreshDatastoreBody)
if !ok {
t.Fatalf("Unexpected response type: %T", r)
}

err := res.Fault()

if test.fail {
Expand All @@ -96,6 +102,9 @@ func TestRefreshDatastore(t *testing.T) {
if err != nil {
t.Error(err)
}
if res.Res == nil {
t.Errorf("Invalid response: %v", res)
}
}
}
}
Expand Down

0 comments on commit 3dac2e7

Please sign in to comment.