Skip to content

Commit ca9f13c

Browse files
committed
Fix test structur
1 parent c8889d7 commit ca9f13c

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

Modules/Tests/StorageTests/GRDB/GRDBManagerTests.swift

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,46 @@ struct GRDBManagerTests {
461461
#expect(variations.allSatisfy { $0.siteID == sampleSiteID })
462462
#expect(variations.allSatisfy { $0.productID == 100 })
463463
}
464+
465+
@Test("Cannot insert product without valid site")
466+
func test_cannot_insert_product_without_valid_site() throws {
467+
// When/Then
468+
#expect(throws: DatabaseError.self) {
469+
try manager.databaseConnection.write { db in
470+
let product = TestProduct(
471+
siteID: 999, // Non-existent site
472+
id: 100,
473+
name: "Orphaned Product",
474+
productTypeKey: "simple",
475+
price: "10.00",
476+
downloadable: false,
477+
parentID: 0,
478+
manageStock: false,
479+
stockStatusKey: ""
480+
)
481+
try product.insert(db)
482+
}
483+
}
484+
}
485+
486+
@Test("Cannot insert variation without valid product")
487+
func test_cannot_insert_variation_without_valid_product() throws {
488+
// When/Then
489+
#expect(throws: DatabaseError.self) {
490+
try manager.databaseConnection.write { db in
491+
let variation = TestProductVariation(
492+
siteID: sampleSiteID,
493+
id: 200,
494+
productID: 999, // Non-existent product
495+
price: "12.00",
496+
downloadable: false,
497+
manageStock: false,
498+
stockStatusKey: ""
499+
)
500+
try variation.insert(db)
501+
}
502+
}
503+
}
464504
}
465505

466506
struct ResetTests {
@@ -601,46 +641,6 @@ struct GRDBManagerTests {
601641

602642
#expect(productCount == 0)
603643
}
604-
605-
@Test("Cannot insert product without valid site")
606-
func test_cannot_insert_product_without_valid_site() throws {
607-
// When/Then
608-
#expect(throws: DatabaseError.self) {
609-
try manager.databaseConnection.write { db in
610-
let product = TestProduct(
611-
siteID: 999, // Non-existent site
612-
id: 100,
613-
name: "Orphaned Product",
614-
productTypeKey: "simple",
615-
price: "10.00",
616-
downloadable: false,
617-
parentID: 0,
618-
manageStock: false,
619-
stockStatusKey: ""
620-
)
621-
try product.insert(db)
622-
}
623-
}
624-
}
625-
626-
@Test("Cannot insert variation without valid product")
627-
func test_cannot_insert_variation_without_valid_product() throws {
628-
// When/Then
629-
#expect(throws: DatabaseError.self) {
630-
try manager.databaseConnection.write { db in
631-
let variation = TestProductVariation(
632-
siteID: sampleSiteID,
633-
id: 200,
634-
productID: 999, // Non-existent product
635-
price: "12.00",
636-
downloadable: false,
637-
manageStock: false,
638-
stockStatusKey: ""
639-
)
640-
try variation.insert(db)
641-
}
642-
}
643-
}
644644
}
645645
}
646646

0 commit comments

Comments
 (0)