Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
41
services/ota_update_go/handlers/issue_get_test.go
Normal file
41
services/ota_update_go/handlers/issue_get_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"otaupdate/handlers"
|
||||
"otaupdate/services"
|
||||
|
||||
mo "github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
|
||||
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
|
||||
)
|
||||
|
||||
func TestIssueGet(t *testing.T) {
|
||||
|
||||
mock := mo.MockIssue{}
|
||||
services.GetDB().SetIssues(&mock)
|
||||
|
||||
tests := []th.BasicHttpTest{
|
||||
{
|
||||
Name: "Invalid Issue ID",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/issues/x", nil),
|
||||
ExpectedStatus: http.StatusNotFound,
|
||||
ExpectedResponse: `{"message":"invalid id","error":"Not Found"}`,
|
||||
},
|
||||
{
|
||||
Name: "Zero Issue ID",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/issues/0", nil),
|
||||
ExpectedStatus: http.StatusBadRequest,
|
||||
ExpectedResponse: `{"message":"id cannot be less than 0","error":"Bad Request"}`,
|
||||
},
|
||||
{
|
||||
Name: "Good Issue Id",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/issues/1", nil),
|
||||
ExpectedStatus: http.StatusOK,
|
||||
ExpectedResponse: `{"data":{"id":1,"vin":"","title":"","description":"","timestamp":"0001-01-01T00:00:00Z","images":[{"id":1,"image":"","issue_id":1}]}}`,
|
||||
},
|
||||
}
|
||||
|
||||
th.RunParamHttpTests(t, tests, handlers.HandleIssueGet, "/issues/:id")
|
||||
}
|
||||
Reference in New Issue
Block a user