package handlers_test

import (
	"github.com/fiskerinc/cloud-services/services/depot/services"

	"github.com/go-pg/pg/v10/orm"

	"github.com/fiskerinc/cloud-services/pkg/common"

	"github.com/fiskerinc/cloud-services/pkg/db/queries/mocks"
	"github.com/fiskerinc/cloud-services/pkg/redis"
	"github.com/fiskerinc/cloud-services/pkg/redis/tester"
)

var mockRedis *redis.Connection
var mockDB *services.DB

func setupRedisMock() {
	mockRedis := tester.NewRedisMock()
	services.SetRedisClientPool(tester.NewMockClientPool(mockRedis))
}

func setupDBMock() {
	db := services.DB{}
	db.SetCars(&mocks.MockCars{
		SelectResponse:    &common.Car{VIN: "FISKER123", ICCID: "1111111111111111111F"},
		SelectCarSettings: []common.CarSetting{},
		SelectCarECUs: []common.CarECU{
			{
				VIN:               "FISKER123",
				ECU:               "ADAS",
				SupplierSWVersion: "ADASVersion",
			},
			{
				VIN:               "FISKER123",
				ECU:               "ACUN",
				SupplierSWVersion: "ACUNVersion",
			},
			{
				VIN:               "FISKER123",
				ECU:               "BCM",
				SupplierSWVersion: "BCMVersion",
			},
		},
	})
	db.SetCarVersionsLog(&mocks.MockCarVersionsLog{MockLogVersionChange: func(log *common.CarVersionLogs) (orm.Result, error) {
		return nil, nil
	}})
	mockDB = &db
	services.SetDB(&db)
}
