queued disk stuff
Some checks are pending
Build and Publish / Metadata (push) Successful in 10s
Build and Publish / BuildAndDeployAmd64 (push) Has started running
Build and Publish / BuildAndDeployArm64 (push) Has started running

This commit is contained in:
matst80
2025-10-13 19:05:12 +02:00
parent 6fbd62936f
commit f3e92c7d65
6 changed files with 87 additions and 38 deletions

View File

@@ -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
}