Skip to content

Commit

Permalink
Make handling of test fixtures consistent
Browse files Browse the repository at this point in the history
A small change to make handling of POST requests
consistent when testing.

Helps ensure that each client side POST request body is
created as expected.
  • Loading branch information
stuart-mclaren-hpe committed Nov 20, 2024
1 parent 7c105f9 commit 27d5893
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/simulator/datastore_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/h2non/gock"
)

//go:embed fixtures/datastores/create/post-request.json
var dsPostRequest string

//go:embed fixtures/datastores/create/hypervisorclustersfiltered.json
var hcFilter string

Expand Down Expand Up @@ -49,6 +52,8 @@ func datastoreCreate() {

gock.New("http://localhost").
Post("/virtualization/v1beta1/datastore").
MatchType("json").
BodyString(dsPostRequest).
Reply(202).
SetHeader("Location", "/data-services/v1beta1/async-operations/"+taskID)

Expand Down
1 change: 1 addition & 0 deletions internal/simulator/datastore_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func datastoreDelete() {

gock.New("http://localhost").
Delete("/virtualization/v1beta1/datastores/"+datastoreID).
BodyString("").
Reply(202).
SetHeader("Location", "/data-services/v1beta1/async-operations/"+taskID).
SetHeader("Content-Type", "application/json").
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"mclaren-ds19","sizeInBytes":17179869184,"storageSystemId":"126fd201-9e6e-5e31-9ffb-a766265b1fd3","targetHypervisorClusterId":"acd4daea-e5e3-5f35-8be3-ce4a4b6d946c","datastoreType":"VMFS"}
{"name":"mclaren-ds19","sizeInBytes":17179869184,"storageSystemId":"126fd201-9e6e-5e31-9ffb-a766265b1fd3","targetHypervisorClusterId":"298a299e-78f5-5acb-86ce-4e9fdc290ab7","datastoreType":"VMFS"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"hypervisor_cluster_ids":["298a299e-78f5-5acb-86ce-4e9fdc290ab7"]}
6 changes: 4 additions & 2 deletions internal/simulator/hypervisorcluster_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"github.com/h2non/gock"
)

//go:embed fixtures/hypervisorclusters/delete/post.json
var hcDeletePost string

//go:embed fixtures/hypervisorclusters/delete/async1.json
var deleteTaskOne string

Expand All @@ -17,13 +20,12 @@ var deleteTaskTwo string
func hypervisorClusterDelete() {
taskID := "a73607cc-ae57-4efe-b573-615813e6c77d"
systemID := "126fd201-9e6e-5e31-9ffb-a766265b1fd3"
clusterID := "298a299e-78f5-5acb-86ce-4e9fdc290ab7"

gock.New("http://localhost").
Post("/private-cloud-business/v1beta1/systems/"+systemID+
"/remove-hypervisor-clusters").
MatchType("json").
JSON(map[string][]string{"hypervisor_cluster_ids": {clusterID}}).
BodyString(hcDeletePost).
Reply(202).
SetHeader("Location", "/data-services/v1beta1/async-operations/"+taskID)

Expand Down

0 comments on commit 27d5893

Please sign in to comment.