feat: make server owner of tabs

This commit is contained in:
2026-10-20 16:15:14 +02:00
parent 5754ae742d
commit 93acfe15a9
26 changed files with 3654 additions and 389 deletions
+11 -14
View File
@@ -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);
});
});