queued disk stuff
This commit is contained in:
@@ -3,6 +3,7 @@ package actor
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"git.tornberg.me/go-cart-actor/pkg/messages"
|
||||
@@ -16,7 +17,7 @@ type cartState struct {
|
||||
func TestRegisteredMutationBasics(t *testing.T) {
|
||||
reg := NewMutationRegistry().(*ProtoMutationRegistry)
|
||||
|
||||
addItemMutation := NewMutation[cartState, *messages.AddItem](
|
||||
addItemMutation := NewMutation(
|
||||
func(state *cartState, msg *messages.AddItem) error {
|
||||
state.calls++
|
||||
// copy to avoid external mutation side-effects (not strictly necessary for the test)
|
||||
@@ -39,13 +40,13 @@ func TestRegisteredMutationBasics(t *testing.T) {
|
||||
|
||||
// RegisteredMutations: membership (order not guaranteed)
|
||||
names := reg.RegisteredMutations()
|
||||
if !stringSliceContains(names, "AddItem") {
|
||||
if !slices.Contains(names, "AddItem") {
|
||||
t.Fatalf("RegisteredMutations missing AddItem, got %v", names)
|
||||
}
|
||||
|
||||
// RegisteredMutationTypes: membership (order not guaranteed)
|
||||
types := reg.RegisteredMutationTypes()
|
||||
if !typeSliceContains(types, reflect.TypeOf(messages.AddItem{})) {
|
||||
if !slices.Contains(types, reflect.TypeOf(messages.AddItem{})) {
|
||||
t.Fatalf("RegisteredMutationTypes missing AddItem type, got %v", types)
|
||||
}
|
||||
|
||||
@@ -131,21 +132,3 @@ func TestRegisteredMutationBasics(t *testing.T) {
|
||||
// }
|
||||
|
||||
// Helpers
|
||||
|
||||
func stringSliceContains(list []string, target string) bool {
|
||||
for _, s := range list {
|
||||
if s == target {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func typeSliceContains(list []reflect.Type, target reflect.Type) bool {
|
||||
for _, t := range list {
|
||||
if t == target {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user