fixes: test failing due to wrong own user ID
authorbuff <andreas@pep-project.org>
Sun, 11 Aug 2019 15:57:37 +0200
changeset 96115645f4b5605a
parent 9610 37b018b92b24
child 9612 c41ea78e2d63
fixes: test failing due to wrong own user ID
pEpForiOSTests/MessageReevalutionTests.swift
     1.1 --- a/pEpForiOSTests/MessageReevalutionTests.swift	Thu Aug 08 14:36:37 2019 +0200
     1.2 +++ b/pEpForiOSTests/MessageReevalutionTests.swift	Sun Aug 11 15:57:37 2019 +0200
     1.3 @@ -28,7 +28,7 @@
     1.4          super.setUp()
     1.5  
     1.6          let ownIdentity = PEPIdentity(address: "iostest002@peptest.ch",
     1.7 -                                      userID: "iostest002@peptest.ch_ID",
     1.8 +                                      userID: CdIdentity.pEpOwnUserID,
     1.9                                        userName: "iOS Test 002",
    1.10                                        isOwn: true)
    1.11  
    1.12 @@ -146,32 +146,6 @@
    1.13          XCTAssertEqual(senderIdentity.pEpRating(), .haveNoKey)
    1.14      }
    1.15  
    1.16 -    func reevaluateMessage(expectedRating: PEPRating, inBackground: Bool = true,
    1.17 -                           infoMessage: String) {
    1.18 -        let message = MessageModelObjectUtils.getMessage(fromCdMessage: cdDecryptedMessage)
    1.19 -
    1.20 -        if inBackground {
    1.21 -            let expReevaluated = expectation(description: "expReevaluated")
    1.22 -            let reevalOp = ReevaluateMessageRatingOperation(parentName: #function, message: message)
    1.23 -            reevalOp.completionBlock = {
    1.24 -                reevalOp.completionBlock = nil
    1.25 -                expReevaluated.fulfill()
    1.26 -            }
    1.27 -            backgroundQueue.addOperation(reevalOp)
    1.28 -            waitForExpectations(timeout: TestUtil.waitTime, handler: { error in
    1.29 -                XCTAssertNil(error)
    1.30 -            })
    1.31 -
    1.32 -            moc.refreshAllObjects()
    1.33 -            XCTAssertEqual(cdDecryptedMessage.pEpRating, Int16(expectedRating.rawValue),
    1.34 -                           infoMessage)
    1.35 -        } else {
    1.36 -            let reevalOp = ReevaluateMessageRatingOperation(
    1.37 -                parentName: #function, message: message)
    1.38 -            reevalOp.reEvaluate()
    1.39 -        }
    1.40 -    }
    1.41 -
    1.42      func testTrustMistrust() {
    1.43          let runReevaluationInBackground = false
    1.44          let senderIdent = senderIdentity.updatedIdentity(session: session)
    1.45 @@ -203,3 +177,34 @@
    1.46          }
    1.47      }
    1.48  }
    1.49 +
    1.50 +// MARK: - HELPER
    1.51 +
    1.52 +extension MessageReevalutionTests {
    1.53 +
    1.54 +    private func reevaluateMessage(expectedRating: PEPRating, inBackground: Bool = true,
    1.55 +                                   infoMessage: String) {
    1.56 +        let message = MessageModelObjectUtils.getMessage(fromCdMessage: cdDecryptedMessage)
    1.57 +
    1.58 +        if inBackground {
    1.59 +            let expReevaluated = expectation(description: "expReevaluated")
    1.60 +            let reevalOp = ReevaluateMessageRatingOperation(parentName: #function, message: message)
    1.61 +            reevalOp.completionBlock = {
    1.62 +                reevalOp.completionBlock = nil
    1.63 +                expReevaluated.fulfill()
    1.64 +            }
    1.65 +            backgroundQueue.addOperation(reevalOp)
    1.66 +            waitForExpectations(timeout: TestUtil.waitTime, handler: { error in
    1.67 +                XCTAssertNil(error)
    1.68 +            })
    1.69 +
    1.70 +            moc.refreshAllObjects()
    1.71 +            XCTAssertEqual(cdDecryptedMessage.pEpRating, Int16(expectedRating.rawValue),
    1.72 +                           infoMessage)
    1.73 +        } else {
    1.74 +            let reevalOp = ReevaluateMessageRatingOperation(
    1.75 +                parentName: #function, message: message)
    1.76 +            reevalOp.reEvaluate()
    1.77 +        }
    1.78 +    }
    1.79 +}