health score
This commit is contained in:
@@ -170,7 +170,7 @@ func indexOf(calls []string, want string) int {
|
||||
// showed the stock climbing and the app never listed the product.
|
||||
func TestReceivingStockPutsTheProductOnTheOutletsShelf(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
err := svc.CreateProductStock([]models.Productstock{{
|
||||
Tenantid: 1135,
|
||||
@@ -200,7 +200,7 @@ func TestReceivingStockPutsTheProductOnTheOutletsShelf(t *testing.T) {
|
||||
// a freshly created row reading "outofstock" until the NEXT delivery.
|
||||
func TestTheShelfIsCreatedBeforeAvailabilityIsDerived(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
if err := svc.CreateProductStock([]models.Productstock{{
|
||||
Tenantid: 1135, Locationid: 1170, Productid: 7086, Quantity: 25, Stocktype: "in",
|
||||
@@ -225,7 +225,7 @@ func TestTheShelfIsCreatedBeforeAvailabilityIsDerived(t *testing.T) {
|
||||
// correctly derived as outofstock — not be silently dropped.
|
||||
func TestAnOutwardMovementAlsoShelves(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
if err := svc.CreateProductStock([]models.Productstock{{
|
||||
Tenantid: 1135, Locationid: 1170, Productid: 7086, Quantity: 3, Stocktype: "out",
|
||||
@@ -245,7 +245,7 @@ func TestReimportingCorrectsAnUncategorisedProduct(t *testing.T) {
|
||||
repo.existing = &models.Products{Productid: 7086, Tenantid: 1135, Categoryid: 0}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{
|
||||
product: &models.CatalogueProduct{ID: 42, Brand: "cadbury", ProductName: "Cadbury Dairy Milk 100g"},
|
||||
})
|
||||
}, nil)
|
||||
|
||||
err := svc.ImportCatalogueProduct([]models.ImportCatalogueProductRequest{{
|
||||
Tenantid: 1135, Locationid: 1170, Brand: "cadbury", Catalogueid: 42,
|
||||
@@ -272,7 +272,7 @@ func TestReimportWithoutACategoryLeavesTheExistingOneAlone(t *testing.T) {
|
||||
repo.existing = &models.Products{Productid: 7043, Tenantid: 1135, Categoryid: 2}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{
|
||||
product: &models.CatalogueProduct{ID: 9, Brand: "generic", ProductName: "Apple"},
|
||||
})
|
||||
}, nil)
|
||||
|
||||
err := svc.ImportCatalogueProduct([]models.ImportCatalogueProductRequest{{
|
||||
Tenantid: 1135, Locationid: 1170, Brand: "generic", Catalogueid: 9,
|
||||
@@ -383,7 +383,7 @@ func (f *fakeProductRepo) GetProducts(params models.ProductFilter) ([]models.Pro
|
||||
// hits and asserts on what a shopper would be shown.
|
||||
func TestTheBrowseEndpointOffersOnlyStockedProducts(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
result, err := svc.GetProductsBySubcategory(models.ProductFilter{
|
||||
CategoryID: 2, TenantID: 1135, LocationID: 1170,
|
||||
@@ -434,7 +434,7 @@ func TestOrderingAnUngroupedProductAsksByProductId(t *testing.T) {
|
||||
repo := &variantRepo{rows: []models.Products{
|
||||
{Productid: 7086, Productname: "Cadbury Dairy Milk 100g", Productstock: 25},
|
||||
}}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
got, err := svc.GetProductByVariant(1135, 0, 1170, 7086)
|
||||
if err != nil {
|
||||
@@ -455,7 +455,7 @@ func TestOrderingAGroupedProductOffersEveryVariant(t *testing.T) {
|
||||
{Productid: 6995, Productname: "Strawberries 250g", Productstock: 4},
|
||||
{Productid: 6996, Productname: "Strawberries 500g", Productstock: 9},
|
||||
}}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
got, err := svc.GetProductByVariant(1087, 44, 1097, 0)
|
||||
if err != nil {
|
||||
@@ -478,7 +478,7 @@ func TestTheProductScreenStillShowsAnEmptyProduct(t *testing.T) {
|
||||
repo := &variantRepo{rows: []models.Products{
|
||||
{Productid: 7085, Productname: "Cadbury 5 Star 18g", Productstock: 0},
|
||||
}}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
got, err := svc.GetProductByVariant(1135, 0, 1170, 7085)
|
||||
if err != nil {
|
||||
@@ -502,7 +502,7 @@ func TestTheWholeFamilyIsShownIncludingEmptyOnes(t *testing.T) {
|
||||
{Productid: 6994, Productname: "Pineapple", Productstock: 50},
|
||||
{Productid: 6989, Productname: "Jammu Apple", Productstock: 0},
|
||||
}}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
got, err := svc.GetProductByVariant(1087, 36, 1097, 7014)
|
||||
if err != nil {
|
||||
@@ -526,7 +526,7 @@ func TestTheWholeFamilyIsShownIncludingEmptyOnes(t *testing.T) {
|
||||
// still does not. The two endpoints deliberately differ.
|
||||
func TestBrowseStillHidesWhatTheShopDoesNotHave(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
result, err := svc.GetProductsBySubcategory(models.ProductFilter{
|
||||
CategoryID: 2, TenantID: 1135, LocationID: 1170,
|
||||
@@ -565,7 +565,7 @@ func TestImportPublishesWhatItPriced(t *testing.T) {
|
||||
ID: 1, Brand: "kohinoor", ProductName: "Kohinoor Charminar Rice 5kg",
|
||||
ImageID: "kohinoor_kohinoor_charminar_rice_5kg",
|
||||
},
|
||||
})
|
||||
}, nil)
|
||||
|
||||
if err := service.ImportCatalogueProduct([]models.ImportCatalogueProductRequest{{
|
||||
Tenantid: 1147, Locationid: 1185, Brand: "kohinoor", Catalogueid: 1,
|
||||
@@ -592,7 +592,7 @@ func TestImportPublishesAfterTheRowsExist(t *testing.T) {
|
||||
repo := newFakeRepo()
|
||||
service := NewProductService(repo, &fakeCatalogueService{
|
||||
product: &models.CatalogueProduct{ID: 1, Brand: "colin", ProductName: "Colin Glass Cleaner 500ml"},
|
||||
})
|
||||
}, nil)
|
||||
|
||||
if err := service.ImportCatalogueProduct([]models.ImportCatalogueProductRequest{{
|
||||
Tenantid: 1147, Locationid: 1185, Brand: "colin", Catalogueid: 1,
|
||||
@@ -789,7 +789,7 @@ func TestPricingFilterDoesNotDisturbTheCallersSlice(t *testing.T) {
|
||||
|
||||
func TestCreateProductReturnsTheIdTheDatabaseAssigned(t *testing.T) {
|
||||
repo := &fakeProductRepo{}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
created, err := svc.CreateProduct(models.Products{
|
||||
Tenantid: 9001,
|
||||
@@ -818,7 +818,7 @@ func TestCreateProductGoesThroughTheOneCreatePath(t *testing.T) {
|
||||
// discarded the id. Only one remains, and this is what pins that: a second
|
||||
// path would have to be added here to be used at all.
|
||||
repo := &fakeProductRepo{}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
if _, err := svc.CreateProduct(models.Products{Tenantid: 9001}); err != nil {
|
||||
t.Fatalf("CreateProduct: %v", err)
|
||||
@@ -834,7 +834,7 @@ func TestAFailedCreateReturnsNoProduct(t *testing.T) {
|
||||
// product with a zero id would be worse than an error — it would send a
|
||||
// price and a stock movement to product 0.
|
||||
repo := &fakeProductRepo{createErr: errors.New("duplicate key")}
|
||||
svc := NewProductService(repo, &fakeCatalogueService{})
|
||||
svc := NewProductService(repo, &fakeCatalogueService{}, nil)
|
||||
|
||||
created, err := svc.CreateProduct(models.Products{Tenantid: 9001, Productsku: "DUP"})
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user