upgrade deps
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
||||
|
||||
// TestCartActorMutationAndState validates end-to-end gRPC mutation + state retrieval
|
||||
// against a locally started gRPC server (single-node scenario).
|
||||
// This test uses AddItemType directly to avoid hitting external product
|
||||
// fetching logic (FetchItem) which would require network I/O.
|
||||
func TestCartActorMutationAndState(t *testing.T) {
|
||||
// Setup local grain pool + synced pool (no discovery, single host)
|
||||
pool := NewGrainLocalPool(1024, time.Minute, spawn)
|
||||
@@ -46,28 +48,34 @@ func TestCartActorMutationAndState(t *testing.T) {
|
||||
// Create a short cart id (<=16 chars so it fits into the fixed CartId 16-byte array cleanly)
|
||||
cartID := fmt.Sprintf("cart-%d", time.Now().UnixNano())
|
||||
|
||||
// Build an AddRequest payload (quantity=1, sku=test-sku)
|
||||
addReq := &messages.AddRequest{
|
||||
// Build an AddItem payload (bypasses FetchItem to keep test deterministic)
|
||||
addItem := &messages.AddItem{
|
||||
ItemId: 1,
|
||||
Quantity: 1,
|
||||
Price: 1000,
|
||||
OrgPrice: 1000,
|
||||
Sku: "test-sku",
|
||||
Name: "Test SKU",
|
||||
Image: "/img.png",
|
||||
Stock: 2, // InStock
|
||||
Tax: 2500,
|
||||
Country: "se",
|
||||
}
|
||||
|
||||
// Marshal underlying mutation payload using the existing handler code path
|
||||
// We can directly marshal with proto since envelope expects raw bytes
|
||||
handler, ok := Handlers[AddRequestType]
|
||||
handler, ok := Handlers[AddItemType]
|
||||
if !ok {
|
||||
t.Fatalf("Handler for AddRequestType missing")
|
||||
t.Fatalf("Handler for AddItemType missing")
|
||||
}
|
||||
payloadData, err := getSerializedPayload(handler, addReq)
|
||||
payloadData, err := getSerializedPayload(handler, AddItemType, addItem)
|
||||
if err != nil {
|
||||
t.Fatalf("serialize add request: %v", err)
|
||||
t.Fatalf("serialize add item: %v", err)
|
||||
}
|
||||
|
||||
// Issue Mutate RPC
|
||||
mutResp, err := cartClient.Mutate(context.Background(), &messages.MutationRequest{
|
||||
CartId: cartID,
|
||||
Type: messages.MutationType(AddRequestType),
|
||||
Type: messages.MutationType(AddItemType),
|
||||
Payload: payloadData,
|
||||
ClientTimestamp: time.Now().Unix(),
|
||||
})
|
||||
@@ -114,9 +122,9 @@ func TestCartActorMutationAndState(t *testing.T) {
|
||||
}
|
||||
|
||||
// getSerializedPayload serializes a mutation proto using the registered handler.
|
||||
func getSerializedPayload(handler MessageHandler, content interface{}) ([]byte, error) {
|
||||
func getSerializedPayload(handler MessageHandler, msgType uint16, content interface{}) ([]byte, error) {
|
||||
msg := &Message{
|
||||
Type: AddRequestType,
|
||||
Type: msgType,
|
||||
Content: content,
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user