mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
|
|
commonv1 "llms.idsbuybuybuy.com/ecommerce/ids-proto/gen/go/ids/common/v1"
|
|
productv1 "llms.idsbuybuybuy.com/ecommerce/ids-proto/gen/go/ids/product/v1"
|
|
)
|
|
|
|
func TestRequireStoreScopeMissing(t *testing.T) {
|
|
_, err := requireStoreScope(&productv1.GetProductRequest{ProductId: "1"})
|
|
if status.Code(err) != codes.FailedPrecondition {
|
|
t.Fatalf("code = %v, want FailedPrecondition", status.Code(err))
|
|
}
|
|
}
|
|
|
|
func TestGetProductBySkuRequiresStoreContext(t *testing.T) {
|
|
s := NewProductServer(nil, nil, nil, nil)
|
|
_, err := s.GetProductBySku(context.Background(), &productv1.GetProductBySkuRequest{})
|
|
if status.Code(err) != codes.FailedPrecondition {
|
|
t.Fatalf("err = %v, want FailedPrecondition", err)
|
|
}
|
|
}
|
|
|
|
func TestGetProductBySkuRequiresID(t *testing.T) {
|
|
s := NewProductServer(nil, nil, nil, nil)
|
|
_, err := s.GetProductBySku(context.Background(), &productv1.GetProductBySkuRequest{
|
|
StoreContext: &commonv1.StoreContext{TenantId: "10", StoreId: "20"},
|
|
})
|
|
if status.Code(err) != codes.InvalidArgument {
|
|
t.Fatalf("err = %v, want InvalidArgument", err)
|
|
}
|
|
}
|