🏡 index : quine-global/quintodrome.git

// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains mock implementations for non-WASM builds.
// These mocks allow IDE support, compilation, and unit testing on non-WASM platforms.
// Plugin authors can use the exported mock instances to set expectations in tests.
//
//go:build !wasip1

package host

import (
	"github.com/stretchr/testify/mock"
)

// QueueConfig represents the QueueConfig data structure.
// QueueConfig holds configuration for a task queue.
type QueueConfig struct {
	Concurrency int32 `json:"concurrency"`
	MaxRetries  int32 `json:"maxRetries"`
	BackoffMs   int64 `json:"backoffMs"`
	DelayMs     int64 `json:"delayMs"`
	RetentionMs int64 `json:"retentionMs"`
}

// TaskInfo represents the TaskInfo data structure.
// TaskInfo holds the current state of a task.
type TaskInfo struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Attempt int32  `json:"attempt"`
}

// mockTaskService is the mock implementation for testing.
type mockTaskService struct {
	mock.Mock
}

// TaskMock is the auto-instantiated mock instance for testing.
// Use this to set expectations: host.TaskMock.On("MethodName", args...).Return(values...)
var TaskMock = &mockTaskService{}

// CreateQueue is the mock method for TaskCreateQueue.
func (m *mockTaskService) CreateQueue(name string, config QueueConfig) error {
	args := m.Called(name, config)
	return args.Error(0)
}

// TaskCreateQueue delegates to the mock instance.
// CreateQueue creates a named task queue with the given configuration.
// Zero-value fields in config use sensible defaults.
// If a queue with the same name already exists, returns an error.
// On startup, this also recovers any stale "running" tasks from a previous crash.
func TaskCreateQueue(name string, config QueueConfig) error {
	return TaskMock.CreateQueue(name, config)
}

// Enqueue is the mock method for TaskEnqueue.
func (m *mockTaskService) Enqueue(queueName string, payload []byte) (string, error) {
	args := m.Called(queueName, payload)
	return args.String(0), args.Error(1)
}

// TaskEnqueue delegates to the mock instance.
// Enqueue adds a task to the named queue. Returns the task ID.
// payload is opaque bytes passed back to the plugin on execution.
func TaskEnqueue(queueName string, payload []byte) (string, error) {
	return TaskMock.Enqueue(queueName, payload)
}

// Get is the mock method for TaskGet.
func (m *mockTaskService) Get(taskID string) (*TaskInfo, error) {
	args := m.Called(taskID)
	var r0 *TaskInfo
	if v := args.Get(0); v != nil {
		r0 = v.(*TaskInfo)
	}
	return r0, args.Error(1)
}

// TaskGet delegates to the mock instance.
// Get returns the current state of a task including its status,
// message, and attempt count.
func TaskGet(taskID string) (*TaskInfo, error) {
	return TaskMock.Get(taskID)
}

// Cancel is the mock method for TaskCancel.
func (m *mockTaskService) Cancel(taskID string) error {
	args := m.Called(taskID)
	return args.Error(0)
}

// TaskCancel delegates to the mock instance.
// Cancel cancels a pending task. Returns error if already
// running, completed, or failed.
func TaskCancel(taskID string) error {
	return TaskMock.Cancel(taskID)
}

// ClearQueue is the mock method for TaskClearQueue.
func (m *mockTaskService) ClearQueue(queueName string) (int64, error) {
	args := m.Called(queueName)
	return args.Get(0).(int64), args.Error(1)
}

// TaskClearQueue delegates to the mock instance.
// ClearQueue removes all pending tasks from the named queue.
// Running tasks are not affected. Returns the number of tasks removed.
func TaskClearQueue(queueName string) (int64, error) {
	return TaskMock.ClearQueue(queueName)
}