This commit is contained in:
matst80
2025-11-27 12:14:09 +01:00
parent 400079ec98
commit 51d7de03d6
7 changed files with 67 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
"github.com/gogo/protobuf/proto"
"github.com/matst80/go-redis-inventory/pkg/inventory"
"google.golang.org/protobuf/types/known/anypb"
"git.k6n.net/go-cart-actor/pkg/actor"
@@ -25,8 +26,28 @@ func newTestGrain() *CartGrain {
return NewCartGrain(123, time.Now())
}
type MockReservationService struct {
}
func (m *MockReservationService) ReserveForCart(ctx context.Context, req inventory.CartReserveRequest) error {
return nil
}
func (m *MockReservationService) ReleaseForCart(ctx context.Context, sku inventory.SKU, locationID inventory.LocationID, cartID inventory.CartID) error {
return nil
}
func (m *MockReservationService) GetAvailableInventory(ctx context.Context, sku inventory.SKU, locationID inventory.LocationID) (uint32, error) {
return 1000, nil
}
func newRegistry() actor.MutationRegistry {
return NewCartMultationRegistry()
cartCtx := &CartMutationContext{
reservationService: &MockReservationService{
reservations: []messages.Reservation{},
},
}
return NewCartMultationRegistry(cartCtx)
}
func msgAddItem(sku string, price int64, qty int32, storePtr *string) *messages.AddItem {