blob: 4655047f717695a750c9b8e99d2ef1ce38bd7f8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//
// HeadRequestTests.swift
// MullvadRESTTests
//
// Created by Marco Nikic on 2024-01-22.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import XCTest
@testable import MullvadMockData
@testable import MullvadREST
class HeadRequestTests: XCTestCase {
func testSuccessfulRequestHasNoError() throws {
let transport = RESTTransportStub(data: Data(), response: HTTPURLResponse())
let request = REST.APIAvailabilityTestRequest(transport: transport)
let successfulRequestExpectation = expectation(description: "HEAD request completed")
_ = request.makeRequest { error in
if error == nil {
successfulRequestExpectation.fulfill()
}
}
wait(for: [successfulRequestExpectation], timeout: .UnitTest.timeout)
}
func testRequestWithErrors() throws {
let transport = RESTTransportStub(error: URLError(.timedOut))
let request = REST.APIAvailabilityTestRequest(transport: transport)
let failedRequestExpectation = expectation(description: "HEAD request failed")
_ = request.makeRequest { error in
if error != nil {
failedRequestExpectation.fulfill()
}
}
wait(for: [failedRequestExpectation], timeout: .UnitTest.timeout)
}
}
|