Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make handling of test fixtures consistent #60

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading