crossmate

A collaborative crossword app for iOS
Log | Files | Refs | LICENSE

PerGameZoneTests.swift (1084B)


      1 import CloudKit
      2 import Foundation
      3 import Testing
      4 
      5 @testable import Crossmate
      6 
      7 @Suite("PerGameZone")
      8 struct PerGameZoneTests {
      9 
     10     @Test("zoneInfo reports unconfirmed local game zones")
     11     @MainActor
     12     func zoneInfoReportsCloudConfirmation() {
     13         let persistence = makeTestPersistence()
     14         let ctx = persistence.viewContext
     15         let id = UUID()
     16         let zoneName = "game-\(id.uuidString)"
     17         let entity = GameEntity(context: ctx)
     18         entity.id = id
     19         entity.title = "Local"
     20         entity.createdAt = Date()
     21         entity.updatedAt = Date()
     22         entity.ckRecordName = zoneName
     23         entity.ckZoneName = zoneName
     24         entity.databaseScope = 0
     25         try? ctx.save()
     26 
     27         let engine = SyncEngine(
     28             container: CloudContainer.container,
     29             persistence: persistence
     30         )
     31         #expect(engine.zoneInfo(forGameID: id, in: ctx)?.isCloudConfirmed == false)
     32 
     33         entity.ckSystemFields = Data([0x01])
     34         try? ctx.save()
     35         #expect(engine.zoneInfo(forGameID: id, in: ctx)?.isCloudConfirmed == true)
     36     }
     37 }