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 TestHandleFlashpackVersionsGetAll(t *testing.T) {
	mock := mo.MockCars{}
	services.GetDB().SetCars(&mock)

	tests := []mo.DBHttpTest{
		{
			Name:             "Get all",
			Request:          th.MakeTestRequest(http.MethodGet, "/flashpack_versions/Ocean/Base/2023", nil),
			ExpectedStatus:   http.StatusOK,
			ExpectedResponse: `{"data":[{"flashpack":"43.19","car_model":"Ocean","car_trim":"Base","car_year":2023},{"flashpack":"41.14","car_model":"Ocean","car_trim":"Base","car_year":2023}],"total":2}`,
		},
	}

	mo.RunParamHttpTests(t, tests, handlers.HandleFlashpackVersionsGetAll, "/flashpack_versions/:model/:trim/:year", &mock)
}
