package service

import (
	"context"

	"github.com/tidbcloud/cluster-service-ng/internal/cluster-agent/internal/sqlexec"
)

type executeMultiCall struct {
	clusterID string
	cmdNames  []string
}

type stubAuditLogExecutor struct {
	errs  []error
	calls []executeMultiCall
}

func (e *stubAuditLogExecutor) ExecuteMulti(
	ctx context.Context,
	clusterID string,
	cmds []sqlexec.Command,
) error {
	_ = ctx

	call := executeMultiCall{
		clusterID: clusterID,
		cmdNames:  make([]string, 0, len(cmds)),
	}
	for _, cmd := range cmds {
		if cmd == nil {
			call.cmdNames = append(call.cmdNames, "<nil>")
			continue
		}
		call.cmdNames = append(call.cmdNames, cmd.Name())
	}

	e.calls = append(e.calls, call)
	idx := len(e.calls) - 1
	if idx < len(e.errs) {
		return e.errs[idx]
	}
	return nil
}
