package regionalapi

import (
	"fmt"
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/tidbcloud/observability/pkg/common/constants"
	"github.com/tidbcloud/observability/pkg/common/errors"
	"github.com/tidbcloud/observability/pkg/resourcemanager"
	"github.com/tidbcloud/observability/test/mockresourcemanager"
	"go.uber.org/mock/gomock"
)

func TestPauseReconcile(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	clusterRW := mockresourcemanager.NewMockClusterReaderWriter(ctrl)
	resourcemanager.MockClusterReaderWriter(clusterRW)
	idNotFound := "12345"
	clusterRW.EXPECT().GetCluster(gomock.Any(), idNotFound).Return(nil, errors.New(errors.ClusterNotFound, "")).AnyTimes()
	w := httptest.NewRecorder()

	t.Run(
		"bad request", func(t *testing.T) {
			req, _ := http.NewRequest("PUT", "/api/v1/ops/clusters/12345/pause-reconcile?pauseCluster=true&vendor=aws&region=us-west-2", nil)
			req.Header.Set(constants.AuthorizationHeader, fmt.Sprintf("%s %s", constants.BearerPrefix, stsToken))
			testEngine.ServeHTTP(w, req)

			assert.Equal(t, http.StatusNotFound, w.Code)
		},
	)

}
