From 7d5f67d2cc730a09a833a3df2a718cedfded6231 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 19 Nov 2018 13:37:06 +0100 Subject: [PATCH] refactor: passing through to the new sdk --- azurerm/helpers/response/response.go | 18 +++---- azurerm/helpers/response/response_test.go | 65 ----------------------- 2 files changed, 6 insertions(+), 77 deletions(-) delete mode 100644 azurerm/helpers/response/response_test.go diff --git a/azurerm/helpers/response/response.go b/azurerm/helpers/response/response.go index 210e5dd784892..4daa7fae31654 100644 --- a/azurerm/helpers/response/response.go +++ b/azurerm/helpers/response/response.go @@ -2,22 +2,16 @@ package response import ( "net/http" + + "github.com/hashicorp/go-azure-helpers/response" ) +// Deprecated: moved to github.com/hashicorp/go-azure-helpers/response func WasConflict(resp *http.Response) bool { - return responseWasStatusCode(resp, http.StatusConflict) + return response.WasConflict(resp) } +// Deprecated: moved to github.com/hashicorp/go-azure-helpers/response func WasNotFound(resp *http.Response) bool { - return responseWasStatusCode(resp, http.StatusNotFound) -} - -func responseWasStatusCode(resp *http.Response, statusCode int) bool { - if r := resp; r != nil { - if r.StatusCode == statusCode { - return true - } - } - - return false + return response.WasNotFound(resp) } diff --git a/azurerm/helpers/response/response_test.go b/azurerm/helpers/response/response_test.go deleted file mode 100644 index 6f0e2be81ff63..0000000000000 --- a/azurerm/helpers/response/response_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package response - -import ( - "net/http" - "testing" -) - -func TestConflict_DroppedConnection(t *testing.T) { - resp := http.Response{} - if WasConflict(&resp) { - t.Fatalf("wasConflict should return `false` for a dropped connection") - } -} - -func TestConflcit_StatusCodes(t *testing.T) { - testCases := []struct { - statusCode int - expectedResult bool - }{ - {http.StatusOK, false}, - {http.StatusInternalServerError, false}, - {http.StatusNotFound, false}, - {http.StatusConflict, true}, - } - - for _, test := range testCases { - resp := http.Response{ - StatusCode: test.statusCode, - } - result := WasConflict(&resp) - if test.expectedResult != result { - t.Fatalf("Expected '%+v' for status code '%d' - got '%+v'", - test.expectedResult, test.statusCode, result) - } - } -} - -func TestNotFound_DroppedConnection(t *testing.T) { - resp := http.Response{} - if WasNotFound(&resp) { - t.Fatalf("wasNotFound should return `false` for a dropped connection") - } -} - -func TestNotFound_StatusCodes(t *testing.T) { - testCases := []struct { - statusCode int - expectedResult bool - }{ - {http.StatusOK, false}, - {http.StatusInternalServerError, false}, - {http.StatusNotFound, true}, - } - - for _, test := range testCases { - resp := http.Response{ - StatusCode: test.statusCode, - } - result := WasNotFound(&resp) - if test.expectedResult != result { - t.Fatalf("Expected '%+v' for status code '%d' - got '%+v'", - test.expectedResult, test.statusCode, result) - } - } -}