Skip to content

Commit 435502f

Browse files
authored
Merge branch 'woomob-1210-basic-mapping-from-POS-entities-to-persisted' into woomob-1210-relationship-based-mapping-and-saving-for-POS-entities
2 parents e3d7b85 + 218d704 commit 435502f

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Modules/Sources/Yosemite/Model/Storage/PersistedProduct+Conversions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension PersistedProductAttribute {
9696
func toProductAttribute(siteID: Int64) -> ProductAttribute {
9797
return ProductAttribute(
9898
siteID: siteID,
99-
attributeID: 0,
99+
attributeID: id ?? 0,
100100
name: name,
101101
position: Int(position),
102102
visible: visible,

Modules/Tests/YosemiteTests/Storage/PersistedProductConversionsTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Testing
55
struct PersistedProductConversionsTests {
66

77
@Test("PersistedProduct init(from:) maps all POSProduct fields")
8-
func test_product_init_from_posProduct_maps_all_fields() throws {
8+
func product_init_from_posProduct_maps_all_fields() throws {
99
// Given
1010
let siteID: Int64 = 1
1111
let productID: Int64 = 10
@@ -24,8 +24,8 @@ struct PersistedProductConversionsTests {
2424
alt: nil)
2525
]
2626
let attributes: [ProductAttribute] = [
27-
ProductAttribute(siteID: siteID, attributeID: 0, name: "Color", position: 0, visible: true, variation: true, options: ["Red", "Blue"]),
28-
ProductAttribute(siteID: siteID, attributeID: 0, name: "Size", position: 1, visible: false, variation: false, options: ["S", "M"])
27+
ProductAttribute(siteID: siteID, attributeID: 0, name: "Color", position: 0, visible: true, variation: true, options: []),
28+
ProductAttribute(siteID: siteID, attributeID: 0, name: "Size", position: 1, visible: false, variation: false, options: [])
2929
]
3030
let pos = POSProduct(
3131
siteID: siteID,
@@ -54,8 +54,8 @@ struct PersistedProductConversionsTests {
5454
#expect(persisted.siteID == siteID)
5555
#expect(persisted.name == pos.name)
5656
#expect(persisted.productTypeKey == pos.productTypeKey)
57-
#expect(persisted.fullDescription == "Full")
58-
#expect(persisted.shortDescription == "Short")
57+
#expect(persisted.fullDescription == pos.fullDescription)
58+
#expect(persisted.shortDescription == pos.shortDescription)
5959
#expect(persisted.sku == pos.sku)
6060
#expect(persisted.globalUniqueID == pos.globalUniqueID)
6161
#expect(persisted.price == pos.price)
@@ -67,7 +67,7 @@ struct PersistedProductConversionsTests {
6767
}
6868

6969
@Test("PersistedProduct toPOSProduct maps back with images and attributes")
70-
func test_product_toPOSProduct_maps_back_including_images_and_attributes() throws {
70+
func product_toPOSProduct_maps_back_including_images_and_attributes() throws {
7171
// Given
7272
let siteID: Int64 = 2
7373
let productID: Int64 = 20
@@ -106,8 +106,8 @@ struct PersistedProductConversionsTests {
106106
]
107107

108108
let persistedAttributes = [
109-
PersistedProductAttribute(productID: productID, name: "Material", position: 0, visible: true, variation: false, options: ["Cotton"]),
110-
PersistedProductAttribute(productID: productID, name: "Fit", position: 1, visible: true, variation: true, options: ["Slim", "Regular"])
109+
PersistedProductAttribute(productID: productID, name: "Material", position: 0, visible: true, variation: false, options: []),
110+
PersistedProductAttribute(productID: productID, name: "Fit", position: 1, visible: true, variation: true, options: [])
111111
]
112112

113113
// When
@@ -137,7 +137,7 @@ struct PersistedProductConversionsTests {
137137
}
138138

139139
@Test("PersistedProductAttribute init(from:) and toProductAttribute round-trip")
140-
func test_product_attribute_round_trip() throws {
140+
func product_attribute_round_trip() throws {
141141
// Given
142142
let siteID: Int64 = 3
143143
let productID: Int64 = 30
@@ -170,7 +170,7 @@ struct PersistedProductConversionsTests {
170170
}
171171

172172
@Test("PersistedProductImage init(from:) and toProductImage round-trip")
173-
func test_product_image_round_trip() throws {
173+
func product_image_round_trip() throws {
174174
// Given
175175
let productID: Int64 = 40
176176
let image = ProductImage(imageID: 400,

Modules/Tests/YosemiteTests/Storage/PersistedProductVariationConversionsTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Testing
55
struct PersistedProductVariationConversionsTests {
66

77
@Test("PersistedProductVariation init(from:) maps all POSProductVariation fields")
8-
func test_variation_init_from_posProductVariation_maps_all_fields() throws {
8+
func variation_init_from_posProductVariation_maps_all_fields() throws {
99
// Given
1010
let siteID: Int64 = 5
1111
let productID: Int64 = 50
@@ -54,7 +54,7 @@ struct PersistedProductVariationConversionsTests {
5454
}
5555

5656
@Test("PersistedProductVariation toPOSProductVariation maps back with attributes and optional image")
57-
func test_variation_toPOSProductVariation_maps_back_including_attributes_and_image() throws {
57+
func variation_toPOSProductVariation_maps_back_including_attributes_and_image() throws {
5858
// Given
5959
let siteID: Int64 = 6
6060
let productID: Int64 = 60
@@ -109,7 +109,7 @@ struct PersistedProductVariationConversionsTests {
109109
}
110110

111111
@Test("PersistedProductVariationAttribute init(from:) and toProductVariationAttribute round-trip")
112-
func test_variation_attribute_round_trip() throws {
112+
func variation_attribute_round_trip() throws {
113113
// Given
114114
let variationID: Int64 = 700
115115
let attr = ProductVariationAttribute(id: 0, name: "Style", option: "Modern")
@@ -128,7 +128,7 @@ struct PersistedProductVariationConversionsTests {
128128
}
129129

130130
@Test("PersistedProductVariationImage init(from:) and toProductImage round-trip")
131-
func test_variation_image_round_trip() throws {
131+
func variation_image_round_trip() throws {
132132
// Given
133133
let variationID: Int64 = 800
134134
let image = ProductImage(imageID: 801,

0 commit comments

Comments
 (0)