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,59 @@
package handlers_test
import (
"net/http"
"testing"
"otaupdate/handlers"
"otaupdate/services"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
"github.com/fiskerinc/cloud-services/pkg/redis"
rm "github.com/fiskerinc/cloud-services/pkg/redis/tester"
th "github.com/fiskerinc/cloud-services/pkg/testhelper"
)
func TestHandleVehicleConnectionStatuses(t *testing.T) {
redis.MockRedisConnection()
mockRedis := rm.MockRedis{
SISMEMBEResults: map[string]map[string]interface{}{
redis.CarSessionsKey(): {
"1G1FP87S3GN100062": int64(0),
"3C4PDCBG0ET127145": int64(1),
},
redis.HMISessionsKey(): {
"1G1FP87S3GN100062": int64(0),
"3C4PDCBG0ET127145": int64(1),
},
},
}
services.SetRedisClientPool(rm.NewMockClientPool(&mockRedis))
tests := []mocks.DBHttpTest{
{
Name: "Good data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/carsconnected", common.VINs{
VINs: []string{"1G1FP87S3GN100062", "3C4PDCBG0ET127145"},
}),
ExpectedStatus: http.StatusOK,
ExpectedResponse: `{"1G1FP87S3GN100062":false,"2:1G1FP87S3GN100062":false,"2:3C4PDCBG0ET127145":true,"3C4PDCBG0ET127145":true}`,
},
{
Name: "No data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/carsconnected", nil),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"VINs required","error":"Bad Request"}`,
},
{
Name: "Bad VIN data",
Request: th.MakeTestRequest(http.MethodPost, "http://example.com/carsconnected", common.VINs{
VINs: []string{"1G1FP87S3GN100062", "XXXXXX"},
}),
ExpectedStatus: http.StatusBadRequest,
ExpectedResponse: `{"message":"VINs[1] 'XXXXXX' invalid","error":"Bad Request"}`,
},
}
mocks.RunDBTests(t, tests, handlers.HandleVehicleConnectionStatuses, nil)
}