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) - } - } -}