Repository: Alamofire/Alamofire
File: Tests/RequestInterceptorTests.swift (Swift)

Code before:
        XCTAssertTrue(result.error is MockError)
    }

    func testThatInterceptorCanAdaptRequestAsynchronously() {
        // Given
        let urlRequest = URLRequest(url: URL(string: "https://httpbin.org/get")!)
        let session = Session()

        let adapter = Adapter { urlRequest, _, completion in
            DispatchQueue.main.async {
                completion(.failure(MockError()))
            }
        }
        let interceptor = Interceptor(adapters: [adapter])

        var result: Result<URLRequest>!

        let completesExpectation = expectation(description: "interceptor completes")

        // When
        interceptor.adapt(urlRequest, for: session) {
            result = $0
            completesExpectation.fulfill()
        }

        _ = waitForExpectations(timeout: 0.01)

        // Then
        XCTAssertTrue(result.isFailure)
        XCTAssertTrue(result.error is MockError)
    }

    func testThatInterceptorCanRetryRequestWithNoRetriers() {
        // Given
        let url = URL(string: "https://httpbin.org/get")!
        let session = Session(startRequestsImmediately: false)
        let request = session.request(url)

        let interceptor = Interceptor()

        var result: RetryResult!

        // When
        interceptor.retry(request, for: session, dueTo: MockError()) { result = $0 }

        // Then
        XCTAssertEqual(result, .doNotRetry)
    }

    func testThatInterceptorCanRetryRequestWithOneRetrier() {
        // Given

Review comment (suggestion):
Please use our default timeout. It should be available as `timeout`. Also, there doesn't seem to be a need for the assignment here.

Code after:
        XCTAssertTrue(result.error is MockError)
    }

    func testThatInterceptorCanAdaptRequestAsynchronously() {
        // Given
        let urlRequest = URLRequest(url: URL(string: "https://httpbin.org/get")!)
        let session = Session()

        let adapter = Adapter { urlRequest, _, completion in
            DispatchQueue.main.async {
                completion(.failure(MockError()))
            }
        }
        let interceptor = Interceptor(adapters: [adapter])

        var result: Result<URLRequest>!

        let completesExpectation = expectation(description: "interceptor completes")

        // When
        interceptor.adapt(urlRequest, for: session) {
            result = $0
            completesExpectation.fulfill()
        }

        waitForExpectations(timeout: timeout)

        // Then
        XCTAssertTrue(result.isFailure)
        XCTAssertTrue(result.error is MockError)
    }

    func testThatInterceptorCanRetryRequestWithNoRetriers() {
        // Given
        let url = URL(string: "https://httpbin.org/get")!
        let session = Session(startRequestsImmediately: false)
        let request = session.request(url)

        let interceptor = Interceptor()

        var result: RetryResult!

        // When
        interceptor.retry(request, for: session, dueTo: MockError()) { result = $0 }

        // Then
        XCTAssertEqual(result, .doNotRetry)
    }

    func testThatInterceptorCanRetryRequestWithOneRetrier() {
        // Given