|
846 | 846 | saving: [imageRecord] |
847 | 847 | ) |
848 | 848 | .notify() |
| 849 | + syncEngine.stop() |
849 | 850 |
|
850 | 851 | inMemoryDataManager.storage.withValue { $0.removeAll() } |
851 | 852 |
|
|
870 | 871 | ) |
871 | 872 | defer { _ = relaunchedSyncEngine } |
872 | 873 |
|
873 | | - let images = try await userDatabase.read { db in |
874 | | - try Image.order(by: \.id).fetchAll(db) |
| 874 | + try await userDatabase.read { db in |
| 875 | + expectNoDifference( |
| 876 | + try Image.order(by: \.id).fetchAll(db), |
| 877 | + [ |
| 878 | + Image(id: 1, image: Data("image".utf8), caption: "A good image") |
| 879 | + ] |
| 880 | + ) |
875 | 881 | } |
876 | 882 |
|
877 | | - expectNoDifference( |
878 | | - images, |
879 | | - [ |
880 | | - Image(id: 1, image: Data("image".utf8), caption: "A good image") |
881 | | - ] |
| 883 | + assertInlineSnapshot(of: relaunchedSyncEngine.container, as: .customDump) { |
| 884 | + """ |
| 885 | + MockCloudContainer( |
| 886 | + privateCloudDatabase: MockCloudDatabase( |
| 887 | + databaseScope: .private, |
| 888 | + storage: [ |
| 889 | + [0]: CKRecord( |
| 890 | + recordID: CKRecord.ID(1:images/zone/__defaultOwner__), |
| 891 | + recordType: "images", |
| 892 | + parent: nil, |
| 893 | + share: nil, |
| 894 | + caption: "A good image", |
| 895 | + id: "1", |
| 896 | + image: Data(5 bytes) |
| 897 | + ) |
| 898 | + ] |
| 899 | + ), |
| 900 | + sharedCloudDatabase: MockCloudDatabase( |
| 901 | + databaseScope: .shared, |
| 902 | + storage: [] |
| 903 | + ) |
| 904 | + ) |
| 905 | + """ |
| 906 | + } |
| 907 | + } |
| 908 | + } |
| 909 | + |
| 910 | + @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
| 911 | + @Test func outsideRecord() async throws { |
| 912 | + let customRecord = CKRecord( |
| 913 | + recordType: "customRecord", |
| 914 | + recordID: CKRecord.ID( |
| 915 | + recordName: "customRecord", |
| 916 | + zoneID: SyncEngine.defaultTestZone.zoneID |
882 | 917 | ) |
| 918 | + ) |
| 919 | + try await syncEngine.modifyRecords(scope: .private, saving: [customRecord]).notify() |
| 920 | + assertQuery(SyncMetadata.all, database: syncEngine.metadatabase) { |
| 921 | + """ |
| 922 | + (No results) |
| 923 | + """ |
| 924 | + } |
| 925 | + } |
| 926 | + |
| 927 | + @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
| 928 | + @Test func outsideRecordWithColon() async throws { |
| 929 | + let customRecord = CKRecord( |
| 930 | + recordType: "customRecord", |
| 931 | + recordID: CKRecord.ID( |
| 932 | + recordName: "1:customRecord", |
| 933 | + zoneID: SyncEngine.defaultTestZone.zoneID |
| 934 | + ) |
| 935 | + ) |
| 936 | + try await syncEngine.modifyRecords(scope: .private, saving: [customRecord]).notify() |
| 937 | + assertQuery(SyncMetadata.all, database: syncEngine.metadatabase) { |
| 938 | + """ |
| 939 | + (No results) |
| 940 | + """ |
883 | 941 | } |
884 | 942 | } |
885 | 943 | } |
|
0 commit comments