Files
tasks/service/history/api/getdlqtasks/api_test.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

88 lines
2.2 KiB
Go

package getdlqtasks_test
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.temporal.io/api/serviceerror"
commonspb "github.com/hanzoai/tasks/api/common/v1"
"github.com/hanzoai/tasks/api/historyservice/v1"
"github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/service/history/api/getdlqtasks"
"github.com/hanzoai/tasks/service/history/consts"
"github.com/hanzoai/tasks/service/history/tasks"
)
// failingHistoryTaskQueueManager is a [persistence.HistoryTaskQueueManager] that always fails.
type failingHistoryTaskQueueManager struct {
persistence.HistoryTaskQueueManager
}
func TestInvoke_InvalidTaskCategory(t *testing.T) {
t.Parallel()
_, err := getdlqtasks.Invoke(context.Background(),
nil,
tasks.NewDefaultTaskCategoryRegistry(),
&historyservice.GetDLQTasksRequest{
DlqKey: &commonspb.HistoryDLQKey{
TaskCategory: -1,
},
})
var invalidArgErr *serviceerror.InvalidArgument
require.ErrorAs(t, err, &invalidArgErr)
assert.ErrorContains(t, invalidArgErr, "Invalid task category")
assert.ErrorContains(t, invalidArgErr, "-1")
}
func TestInvoke_ZeroPageSize(t *testing.T) {
t.Parallel()
_, err := getdlqtasks.Invoke(
context.Background(),
new(persistence.HistoryTaskQueueManagerImpl),
tasks.NewDefaultTaskCategoryRegistry(),
&historyservice.GetDLQTasksRequest{
DlqKey: &commonspb.HistoryDLQKey{
TaskCategory: int32(tasks.CategoryTransfer.ID()),
},
PageSize: 0,
},
)
assert.ErrorIs(t, err, consts.ErrInvalidPageSize)
}
func TestInvoke_UnavailableError(t *testing.T) {
t.Parallel()
_, err := getdlqtasks.Invoke(
context.Background(),
failingHistoryTaskQueueManager{},
tasks.NewDefaultTaskCategoryRegistry(),
&historyservice.GetDLQTasksRequest{
DlqKey: &commonspb.HistoryDLQKey{
TaskCategory: int32(tasks.CategoryTransfer.ID()),
},
PageSize: 0,
},
)
var unavailableErr *serviceerror.Unavailable
require.ErrorAs(t, err, &unavailableErr)
assert.ErrorContains(t, unavailableErr, "some random error")
}
func (m failingHistoryTaskQueueManager) ReadRawTasks(
context.Context,
*persistence.ReadRawTasksRequest,
) (*persistence.ReadRawTasksResponse, error) {
return nil, errors.New("some random error")
}