package handlers_test

import (
	"testing"

	"github.com/fiskerinc/cloud-services/services/attendant/handlers"
	"github.com/fiskerinc/cloud-services/services/attendant/services"

	"github.com/fiskerinc/cloud-services/pkg/redis/tester"
	"github.com/fiskerinc/cloud-services/pkg/testhelper"
)

func TestApproveUpdate(t *testing.T) {
	mockRedis := &tester.MockRedis{}
	services.SetRedisClientPool(tester.NewMockClientPool(mockRedis))

	data := []byte(`{"id": 1}`)

	err := handlers.ApproveUpdate(mockDB, "FISKER123", data)
	if err != nil {
		t.Errorf(testhelper.TestErrorTemplate, "ApproveUpdate", "no error", err)
	}

	err = handlers.ApproveUpdate(mockDB, "FISKER123", nil)
	if err == nil {
		t.Errorf(testhelper.TestErrorTemplate, "ApproveUpdate", "error", err)
	}
}
