@@ -867,4 +867,50 @@ final class EnumeratorTests: XCTestCase {
867867 XCTAssertNotNil ( Self . dbManager. itemMetadata ( ocId: remoteTrashItemB. identifier) )
868868 XCTAssertNotNil ( Self . dbManager. itemMetadata ( ocId: remoteTrashItemC. identifier) )
869869 }
870+
871+ func testTrashItemEnumerationFailWhenNoTrashInCapabilities( ) async {
872+ let remoteInterface = MockRemoteInterface ( rootItem: rootItem, rootTrashItem: rootTrashItem)
873+ XCTAssert ( remoteInterface. capabilities. contains ( ##""undelete": true,"## ) )
874+ remoteInterface. capabilities =
875+ remoteInterface. capabilities. replacingOccurrences ( of: ##""undelete": true,"## , with: " " )
876+
877+ let db = Self . dbManager. ncDatabase ( ) // Strong ref for in memory test db
878+ debugPrint ( db) // Avoid build-time warning about unused variable, ensure compiler won't free
879+ let enumerator = Enumerator (
880+ enumeratedItemIdentifier: . trashContainer,
881+ account: Self . account,
882+ remoteInterface: remoteInterface,
883+ dbManager: Self . dbManager
884+ )
885+ let observer = MockEnumerationObserver ( enumerator: enumerator)
886+ do {
887+ try await observer. enumerateItems ( )
888+ XCTFail ( " Item enumeration should have failed! " )
889+ } catch let error {
890+ XCTAssertEqual ( ( error as NSError ? ) ? . code, NSFeatureUnsupportedError)
891+ }
892+ }
893+
894+ func testTrashChangeEnumerationFailWhenNoTrashInCapabilities( ) async {
895+ let remoteInterface = MockRemoteInterface ( rootItem: rootItem, rootTrashItem: rootTrashItem)
896+ XCTAssert ( remoteInterface. capabilities. contains ( ##""undelete": true,"## ) )
897+ remoteInterface. capabilities =
898+ remoteInterface. capabilities. replacingOccurrences ( of: ##""undelete": true,"## , with: " " )
899+
900+ let db = Self . dbManager. ncDatabase ( ) // Strong ref for in memory test db
901+ debugPrint ( db) // Avoid build-time warning about unused variable, ensure compiler won't free
902+ let enumerator = Enumerator (
903+ enumeratedItemIdentifier: . trashContainer,
904+ account: Self . account,
905+ remoteInterface: remoteInterface,
906+ dbManager: Self . dbManager
907+ )
908+ let observer = MockChangeObserver ( enumerator: enumerator)
909+ do {
910+ try await observer. enumerateChanges ( )
911+ XCTFail ( " Item enumeration should have failed! " )
912+ } catch let error {
913+ XCTAssertEqual ( ( error as NSError ? ) ? . code, NSFeatureUnsupportedError)
914+ }
915+ }
870916}
0 commit comments