package asyncappbox

import (
	"testing"

	"github.com/tidbcloud/infra-provider/pkg/consts"
	"github.com/tidbcloud/infra-provider/regional-server/api/v1alpha1"
	"github.com/tidbcloud/infra-provider/regional-server/pkg/config"
	"github.com/tidbcloud/infra-provider/regional-server/pkg/controllers/appbox/task"
)

func TestAsyncGetAPPBoxTasks(t *testing.T) {
	initCtx := &task.Context{
		APPBox: &v1alpha1.APPBox{},
		Config: config.RootConfig{
			ControllerConfig: config.ControllerConfig{
				Provider: consts.ProviderTypeEKS,
			},
		},
	}
	gkeTaskCount := 2
	t.Run("async gke task", func(t *testing.T) {
		ctx := initCtx
		ctx.Config.Provider = consts.ProviderTypeGKE
		ctx.APPBox = &v1alpha1.APPBox{}
		tasks := GetAsyncAPPBoxTasks(&AsyncAPPBoxReconciler{}, ctx)
		if len(tasks) != gkeTaskCount {
			t.Errorf("expected %d tasks, got %d", gkeTaskCount, len(tasks))
		}
	})
}
