package tempcorecli

import (
	"context"
	"fmt"
	"slices"

	coreapi "github.com/tidbcloud/core-svc/idl/pbgen/proto/core"
)

// Deprecated: For newly-written tests, use mock in tests instead. Do not add mock data here.
type fakeImpl struct{}

func (c fakeImpl) GetCluster(ctx context.Context, clusterID uint64) (*coreapi.Cluster, error) {
	return &coreapi.Cluster{
		Id:        clusterID,
		TenantId:  2,
		ProjectId: 3,
		Name:      "fake-cluster",
	}, nil
}

func (c fakeImpl) ListClusters(ctx context.Context, req *coreapi.ListClustersReq) (*coreapi.ListClustersResp, error) {
	resp := &coreapi.ListClustersResp{
		Clusters:          make(map[uint64]*coreapi.Cluster),
		OrderedClusterIds: make([]uint64, 0),
	}
	for _, id := range req.Filter.ClusterIds {
		resp.Clusters[id] = &coreapi.Cluster{
			Id:        id,
			TenantId:  2,
			ProjectId: 3,
			Name:      fmt.Sprintf("fake-cluster-%d", id),
		}
		resp.OrderedClusterIds = append(resp.OrderedClusterIds, id)
	}

	slices.Sort(resp.OrderedClusterIds)
	return resp, nil
}
