From 5e013d0d327dee9f5cd53fee6ec8d2d2593e0258 Mon Sep 17 00:00:00 2001 From: "Igor D.C" Date: Thu, 8 Oct 2020 18:44:14 +0000 Subject: Restore commented unit test TestDeleteLogicalCloud Restore the previously commented-out unit test TestDeleteLogicalCloud. That test was disabled due to a failure introduced by interacting with AppContext for the first time in module/logicalcloud.go and it not being ready to do so. This commit restores it and modifies code so dependent mocks can plug in correctly. This was done in order to keep testing the code that was previously being tested, not so much to add additional coverage. Although it would be a significant undertaking, the different types and interfaces in pkg/module should be redesigned to achieve better decoupling and thus make unit testing more straightforward. Issue-ID: MULTICLOUD-1143 Change-Id: I1e6b7bb9111fc6883f0c9cee887329a9e0b27fbd Signed-off-by: Igor D.C --- src/dcm/api/logicalCloudHandler.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/dcm/api') diff --git a/src/dcm/api/logicalCloudHandler.go b/src/dcm/api/logicalCloudHandler.go index b305b202..ad9a3807 100644 --- a/src/dcm/api/logicalCloudHandler.go +++ b/src/dcm/api/logicalCloudHandler.go @@ -26,7 +26,6 @@ import ( "github.com/gorilla/mux" "github.com/onap/multicloud-k8s/src/dcm/pkg/module" orch "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module" - pkgerrors "github.com/pkg/errors" ) // logicalCloudHandler is used to store backend implementations objects @@ -266,13 +265,6 @@ func (h logicalCloudHandler) terminateHandler(w http.ResponseWriter, r *http.Req return } - _, ctxVal, err := h.client.GetLogicalCloudContext(project, name) - if ctxVal == "" { - err = pkgerrors.New("Logical Cloud hasn't been applied yet") - http.Error(w, err.Error(), http.StatusConflict) - return - } - // Get Clusters clusters, err := h.clusterClient.GetAllClusters(project, name) @@ -291,8 +283,11 @@ func (h logicalCloudHandler) terminateHandler(w http.ResponseWriter, r *http.Req // Terminate the Logical Cloud err = module.Terminate(project, lc, clusters, quotas) if err != nil { + if err.Error() == "Logical Cloud doesn't seem applied: "+name { + http.Error(w, err.Error(), http.StatusConflict) + return + } http.Error(w, err.Error(), http.StatusInternalServerError) - return } return -- cgit 1.2.3-korg