even more refactoring
Some checks failed
Build and Publish / BuildAndDeploy (push) Successful in 3m7s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
matst80
2025-10-10 11:46:19 +00:00
parent 12d87036f6
commit 716f1121aa
32 changed files with 3857 additions and 953 deletions

View File

@@ -12,7 +12,7 @@ import (
// TestCartActorMutationAndState validates end-to-end gRPC mutation + state retrieval
// against a locally started gRPC server (single-node scenario).
// This test uses the oneof MutationEnvelope directly to avoid hitting external product
// This test uses the new per-mutation AddItem RPC (breaking v2 API) to avoid external product fetch logic
// fetching logic (FetchItem) which would require network I/O.
func TestCartActorMutationAndState(t *testing.T) {
// Setup local grain pool + synced pool (no discovery, single host)
@@ -60,32 +60,29 @@ func TestCartActorMutationAndState(t *testing.T) {
Country: "se",
}
// Build oneof envelope directly (no legacy handler/enum)
envelope := &messages.MutationEnvelope{
// Issue AddItem RPC directly (breaking v2 API)
addResp, err := cartClient.AddItem(context.Background(), &messages.AddItemRequest{
CartId: cartID,
ClientTimestamp: time.Now().Unix(),
Mutation: &messages.MutationEnvelope_AddItem{
AddItem: addItem,
},
}
// Issue Mutate RPC
mutResp, err := cartClient.Mutate(context.Background(), envelope)
Payload: addItem,
})
if err != nil {
t.Fatalf("Mutate RPC error: %v", err)
t.Fatalf("AddItem RPC error: %v", err)
}
if mutResp.StatusCode != 200 {
t.Fatalf("Mutate returned non-200 status: %d, error: %s", mutResp.StatusCode, mutResp.GetError())
if addResp.StatusCode != 200 {
t.Fatalf("AddItem returned non-200 status: %d, error: %s", addResp.StatusCode, addResp.GetError())
}
// Validate the response state
state := mutResp.GetState()
// Validate the response state (from AddItem)
state := addResp.GetState()
if state == nil {
t.Fatalf("Mutate response state is nil")
t.Fatalf("AddItem response state is nil")
}
// (Removed obsolete Mutate response handling)
if len(state.Items) != 1 {
t.Fatalf("Expected 1 item after mutation, got %d", len(state.Items))
t.Fatalf("Expected 1 item after AddItem, got %d", len(state.Items))
}
if state.Items[0].Sku != "test-sku" {
t.Fatalf("Unexpected item SKU: %s", state.Items[0].Sku)