@@ -170,134 +170,6 @@ struct POSCatalogFullSyncServiceTests {
170170 }
171171}
172172
173- // MARK: - Mock POSCatalogSyncRemote
174-
175- final class MockPOSCatalogSyncRemote : POSCatalogSyncRemoteProtocol {
176- // Dictionary mapping pageNumber to Result for products and variations.
177- private( set) var productResults : [ Int : Result < PagedItems < POSProduct > , Error > ] = [ : ]
178- private( set) var variationResults : [ Int : Result < PagedItems < POSProductVariation > , Error > ] = [ : ]
179- private( set) var incrementalProductResults : [ Int : Result < PagedItems < POSProduct > , Error > ] = [ : ]
180- private( set) var incrementalVariationResults : [ Int : Result < PagedItems < POSProductVariation > , Error > ] = [ : ]
181-
182- private( set) var loadProductsCallCount = 0
183- private( set) var loadProductVariationsCallCount = 0
184- private( set) var loadIncrementalProductsCallCount = 0
185- private( set) var loadIncrementalProductVariationsCallCount = 0
186-
187- private( set) var lastIncrementalProductsModifiedAfter : Date ?
188- private( set) var lastIncrementalVariationsModifiedAfter : Date ?
189-
190- // Fallback result when no specific page result is configured
191- private let fallbackResult = PagedItems ( items: [ ] as [ POSProduct ] , hasMorePages: false , totalItems: 0 )
192- private let fallbackVariationResult = PagedItems ( items: [ ] as [ POSProductVariation ] , hasMorePages: false , totalItems: 0 )
193-
194- // MARK: - Setup Methods for Full Sync
195-
196- func setProductResult( pageNumber: Int , result: Result < PagedItems < POSProduct > , Error > ) {
197- productResults [ pageNumber] = result
198- }
199-
200- func setVariationResult( pageNumber: Int , result: Result < PagedItems < POSProductVariation > , Error > ) {
201- variationResults [ pageNumber] = result
202- }
203-
204- func setProductResults( _ results: [ PagedItems < POSProduct > ] ) {
205- for (index, pagedItems) in results. enumerated ( ) {
206- productResults [ index + 1 ] = . success( pagedItems)
207- }
208- }
209-
210- func setVariationResults( _ results: [ PagedItems < POSProductVariation > ] ) {
211- for (index, pagedItems) in results. enumerated ( ) {
212- variationResults [ index + 1 ] = . success( pagedItems)
213- }
214- }
215-
216- // MARK: - Setup Methods for Incremental Sync
217-
218- func setIncrementalProductResult( pageNumber: Int , result: Result < PagedItems < POSProduct > , Error > ) {
219- incrementalProductResults [ pageNumber] = result
220- }
221-
222- func setIncrementalVariationResult( pageNumber: Int , result: Result < PagedItems < POSProductVariation > , Error > ) {
223- incrementalVariationResults [ pageNumber] = result
224- }
225-
226- func setIncrementalProductResults( _ results: [ PagedItems < POSProduct > ] ) {
227- for (index, pagedItems) in results. enumerated ( ) {
228- incrementalProductResults [ index + 1 ] = . success( pagedItems)
229- }
230- }
231-
232- func setIncrementalVariationResults( _ results: [ PagedItems < POSProductVariation > ] ) {
233- for (index, pagedItems) in results. enumerated ( ) {
234- incrementalVariationResults [ index + 1 ] = . success( pagedItems)
235- }
236- }
237-
238- // MARK: - Protocol Methods - Incremental Sync
239-
240- func loadProducts( modifiedAfter: Date , siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProduct > {
241- loadIncrementalProductsCallCount += 1
242- lastIncrementalProductsModifiedAfter = modifiedAfter
243-
244- if let result = incrementalProductResults [ pageNumber] {
245- switch result {
246- case . success( let pagedItems) :
247- return pagedItems
248- case . failure( let error) :
249- throw error
250- }
251- }
252- return fallbackResult
253- }
254-
255- func loadProductVariations( modifiedAfter: Date , siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProductVariation > {
256- loadIncrementalProductVariationsCallCount += 1
257- lastIncrementalVariationsModifiedAfter = modifiedAfter
258-
259- if let result = incrementalVariationResults [ pageNumber] {
260- switch result {
261- case . success( let pagedItems) :
262- return pagedItems
263- case . failure( let error) :
264- throw error
265- }
266- }
267- return fallbackVariationResult
268- }
269-
270- // MARK: - Protocol Methods - Full Sync
271-
272- func loadProducts( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProduct > {
273- loadProductsCallCount += 1
274-
275- if let result = productResults [ pageNumber] {
276- switch result {
277- case . success( let pagedItems) :
278- return pagedItems
279- case . failure( let error) :
280- throw error
281- }
282- }
283- return fallbackResult
284- }
285-
286- func loadProductVariations( siteID: Int64 , pageNumber: Int ) async throws -> PagedItems < POSProductVariation > {
287- loadProductVariationsCallCount += 1
288-
289- if let result = variationResults [ pageNumber] {
290- switch result {
291- case . success( let pagedItems) :
292- return pagedItems
293- case . failure( let error) :
294- throw error
295- }
296- }
297- return fallbackVariationResult
298- }
299- }
300-
301173// MARK: - Mock POSCatalogPersistenceService
302174
303175private final class MockPOSCatalogPersistenceService : POSCatalogPersistenceServiceProtocol {
0 commit comments