IOS-647 ignorable fake messages for tests IOS-647
authorbuff <andreas@pep-project.org>
Mon, 07 Jan 2019 12:51:00 +0100
branchIOS-647
changeset 74391306a841b8b6
parent 7438 7bf0a6623aa1
child 7440 790b3f124563
IOS-647 ignorable fake messages for tests
pEpForiOSTests/SimpleOperationsTest.swift
pEpForiOSTests/TestUtils/CdMessage+TestUtils.swift
     1.1 --- a/pEpForiOSTests/SimpleOperationsTest.swift	Mon Jan 07 10:44:27 2019 +0100
     1.2 +++ b/pEpForiOSTests/SimpleOperationsTest.swift	Mon Jan 07 12:51:00 2019 +0100
     1.3 @@ -461,7 +461,7 @@
     1.4          })
     1.5          // Check sent status of all sent mails
     1.6          for sentUuid in sentUUIDs {
     1.7 -            let msgs = CdMessage.search(byUUID: sentUuid)
     1.8 +            let msgs = CdMessage.search(byUUID: sentUuid, includeFakeMessages: false)
     1.9              XCTAssertEqual(msgs.count, 1)
    1.10              guard let msg = msgs.first else {
    1.11                  XCTFail("Missing sent message")
     2.1 --- a/pEpForiOSTests/TestUtils/CdMessage+TestUtils.swift	Mon Jan 07 10:44:27 2019 +0100
     2.2 +++ b/pEpForiOSTests/TestUtils/CdMessage+TestUtils.swift	Mon Jan 07 12:51:00 2019 +0100
     2.3 @@ -7,6 +7,7 @@
     2.4  //
     2.5  
     2.6  import MessageModel
     2.7 +@testable import pEpForiOS
     2.8  
     2.9  extension CdMessage {
    2.10      func isValidMessage() -> Bool {
    2.11 @@ -15,4 +16,20 @@
    2.12              || self.attachments?.count ?? 0 > 0
    2.13              || self.shortMessage != nil
    2.14      }
    2.15 +
    2.16 +    public static func search(byUUID uuid: MessageID, includeFakeMessages: Bool) -> [CdMessage] {
    2.17 +        return by(uuid: uuid, includeFakeMessages: includeFakeMessages)
    2.18 +    }
    2.19 +
    2.20 +    static func by(uuid: MessageID, includeFakeMessages: Bool) -> [CdMessage] {
    2.21 +        if includeFakeMessages {
    2.22 +            return CdMessage.all(predicate: NSPredicate(format: "uuid = %@", uuid))
    2.23 +                as? [CdMessage] ?? []
    2.24 +        } else {
    2.25 +            return CdMessage.all(predicate: NSPredicate(format: "uuid = %@ AND uid != %d",
    2.26 +                                                        uuid,
    2.27 +                                                        Int32(Message.uidFakeResponsivenes)))
    2.28 +                as? [CdMessage] ?? []
    2.29 +        }
    2.30 +    }
    2.31  }