Files
async-http-client/Tests/AsyncHTTPClientTests/HTTPClientResponseTests.swift
T
Si BeaumontandGitHub a4904fcc6b Add missing availability guards in tests (#719)
## Motivation

Some of the test code was missing availability guards for Apple platforms, resulting in build failures for these platforms, e.g.

```
error: 'AsyncSequence' is only available in iOS 13.0 or newer
```

## Modifications

Add missing availability guards. I've tried to keep them as scoped as possible.

## Result

Tests can now build for run on iOS and other Apple platforms.
2023-12-18 04:52:50 -08:00

47 lines
1.8 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the AsyncHTTPClient open source project
//
// Copyright (c) 2023 Apple Inc. and the AsyncHTTPClient project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
@testable import AsyncHTTPClient
import Logging
import NIOCore
import XCTest
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
final class HTTPClientResponseTests: XCTestCase {
func testSimpleResponse() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .GET, headers: ["content-length": "1025"], status: .ok)
XCTAssertEqual(response, 1025)
}
func testSimpleResponseNotModified() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .GET, headers: ["content-length": "1025"], status: .notModified)
XCTAssertEqual(response, 0)
}
func testSimpleResponseHeadRequestMethod() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .HEAD, headers: ["content-length": "1025"], status: .ok)
XCTAssertEqual(response, 0)
}
func testResponseNoContentLengthHeader() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .GET, headers: [:], status: .ok)
XCTAssertEqual(response, nil)
}
func testResponseInvalidInteger() {
let response = HTTPClientResponse.expectedContentLength(requestMethod: .GET, headers: ["content-length": "none"], status: .ok)
XCTAssertEqual(response, nil)
}
}