feat: make server owner of tabs
This commit is contained in:
@@ -223,7 +223,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('throws when not enough stock', () async {
|
||||
test('goes below zero instead of refusing', () async {
|
||||
await database
|
||||
.into(database.products)
|
||||
.insert(
|
||||
@@ -237,10 +237,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
() => service.decreaseStock('low-stock', 5),
|
||||
throwsA(isA<InsufficientStockException>()),
|
||||
);
|
||||
await service.decreaseStock('low-stock', 5);
|
||||
|
||||
final product = await service.getProductById('low-stock');
|
||||
expect(product!.stockQuantity, -2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -296,7 +296,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('does not allow concurrent decrements below zero', () async {
|
||||
test('counts every concurrent decrement', () async {
|
||||
await database
|
||||
.into(database.products)
|
||||
.insert(
|
||||
@@ -310,16 +310,13 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
await expectLater(
|
||||
Future.wait([
|
||||
service.decreaseStock('concurrent-stock', 1),
|
||||
service.decreaseStock('concurrent-stock', 1),
|
||||
]),
|
||||
throwsA(isA<InsufficientStockException>()),
|
||||
);
|
||||
await Future.wait([
|
||||
service.decreaseStock('concurrent-stock', 1),
|
||||
service.decreaseStock('concurrent-stock', 1),
|
||||
]);
|
||||
|
||||
final product = await service.getProductById('concurrent-stock');
|
||||
expect(product!.stockQuantity, 0);
|
||||
expect(product!.stockQuantity, -1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user