Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
40
services/ota_update_go/handlers/issues_delete_test.go
Normal file
40
services/ota_update_go/handlers/issues_delete_test.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"otaupdate/handlers"
|
||||
"otaupdate/services"
|
||||
|
||||
"github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
|
||||
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
|
||||
)
|
||||
|
||||
func TestIssuesDelete(t *testing.T) {
|
||||
db := services.GetDB()
|
||||
|
||||
db.SetIssues(&mocks.MockIssue{})
|
||||
tests := []th.BasicHttpTest{
|
||||
{
|
||||
Name: "Invalid ID",
|
||||
Request: th.MakeTestRequest(http.MethodDelete, "http://example.com/issues/x", nil),
|
||||
ExpectedStatus: http.StatusBadRequest,
|
||||
ExpectedResponse: `{"message":"strconv.Atoi: parsing \"x\": invalid syntax","error":"Bad Request"}`,
|
||||
},
|
||||
{
|
||||
Name: "Zero id",
|
||||
Request: th.MakeTestRequest(http.MethodDelete, "http://example.com/issues/0", nil),
|
||||
ExpectedStatus: http.StatusBadRequest,
|
||||
ExpectedResponse: `{"message":"id cannot be less than 0","error":"Bad Request"}`,
|
||||
},
|
||||
{
|
||||
Name: "Good Request",
|
||||
Request: th.MakeTestRequest(http.MethodDelete, "http://example.com/issues/1", nil),
|
||||
ExpectedStatus: http.StatusOK,
|
||||
ExpectedResponse: `{"message":"Deleted"}`,
|
||||
},
|
||||
}
|
||||
|
||||
th.RunParamHttpTests(t, tests, handlers.HandleIssuesDelete, "/issues/:id")
|
||||
}
|
||||
Reference in New Issue
Block a user