Files
tasks/common/collection/indexedtakelist_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

48 lines
1023 B
Go

package collection_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/hanzoai/tasks/common/collection"
)
func TestIndexedTakeList(t *testing.T) {
t.Parallel()
type Value struct{ ID int }
values := []Value{{ID: 0}, {ID: 1}, {ID: 2}, {ID: 3}, {ID: 4}}
indexer := func(v Value) int { return v.ID }
list := collection.NewIndexedTakeList(values, indexer)
t.Run("take absent", func(t *testing.T) {
_, ok := list.Take(999)
require.False(t, ok)
})
t.Run("take present", func(t *testing.T) {
v, ok := list.Take(3)
require.True(t, ok)
require.Equal(t, 3, v.ID)
})
t.Run("take taken", func(t *testing.T) {
_, ok := list.Take(3)
require.False(t, ok)
})
t.Run("take remaining", func(t *testing.T) {
allowed := []int{0, 1, 2, 4}
remaining := list.TakeRemaining()
require.Len(t, remaining, len(allowed))
for _, v := range remaining {
require.Contains(t, allowed, v.ID)
}
})
t.Run("now empty", func(t *testing.T) {
require.Empty(t, list.TakeRemaining())
})
}