Add depot, attendant, jetfire, optimus, ota services with kustomize overlays
This commit is contained in:
37
services/ota_update_go/handlers/vehicleyears_get_test.go
Normal file
37
services/ota_update_go/handlers/vehicleyears_get_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package handlers_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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 TestGetVehicleYears(t *testing.T) {
|
||||
mock := mo.MockCars{}
|
||||
services.GetDB().SetCars(&mock)
|
||||
tests := []mo.DBHttpTest{
|
||||
{
|
||||
Name: "Call",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicleyears", nil),
|
||||
ExpectedStatus: http.StatusOK,
|
||||
ExpectedResponse: `{"data":[3000]}`,
|
||||
},
|
||||
{
|
||||
Name: "Error",
|
||||
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicleyears", nil),
|
||||
ExpectedStatus: http.StatusServiceUnavailable,
|
||||
ExpectedResponse: `{"message":"something went wrong","error":"Service Unavailable"}`,
|
||||
DBTestCase: mo.DBTestCase{
|
||||
MockError: fmt.Errorf("something went wrong"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
mo.RunDBTests(t, tests, handlers.HandleVehicleYears, &mock)
|
||||
}
|
||||
Reference in New Issue
Block a user