Add depot, attendant, jetfire, optimus, ota services with kustomize overlays

This commit is contained in:
Chris Rai
2026-01-31 15:35:07 -05:00
parent a0ec642ca1
commit 9a5cb2f547
404 changed files with 38817 additions and 16 deletions

View File

@@ -0,0 +1,50 @@
package handlers_test
import (
"net/http"
"otaupdate/handlers"
"otaupdate/services"
"testing"
mo "github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
)
func TestHandleVersionGet(t *testing.T) {
mock := mo.MockCarVersionsLog{
GetCarVersionsResult: map[string]string{
"DBC": "dbc-version",
"TREX": "trex-version",
},
}
services.GetDB().SetCarVersionsLog(&mock)
tests := []th.BasicHttpTest{
{
Name: "Invalid VIN",
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicle/1111/version", nil),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"VIN '1111' invalid","error":"Bad Request"}`,
},
{
Name: "Invalid timestamp",
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicle/11111111111111111/version?timestamp=99-99-99", nil),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"Timestamp yyyymmdddate ","error":"Bad Request"}`,
},
{
Name: "Good request no timestamp",
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicle/11111111111111111/version", nil),
ExpectedStatus: http.StatusOK,
ExpectedResponse: `{"DBC":"dbc-version","TREX":"trex-version"}`,
},
{
Name: "Good request with timestamp",
Request: th.MakeTestRequest(http.MethodGet, "http://example.com/vehicle/11111111111111111/version?timestamp=2023-01-30", nil),
ExpectedStatus: http.StatusOK,
ExpectedResponse: `{"DBC":"dbc-version","TREX":"trex-version"}`,
},
}
th.RunParamHttpTests(t, tests, handlers.HandleVersionsGet, "/vehicle/:vin/version")
}