From e843c0bbc804ebf126d112c7ada2ad0b7c3a9948 Mon Sep 17 00:00:00 2001 From: Katherine Bertelsen Date: Tue, 19 Mar 2024 16:04:17 -0500 Subject: [PATCH] BIT-273: Rename old unit tests to follow standard --- .../Core/Auth/Models/Response/ErrorResponseModelTests.swift | 4 ++-- .../Models/Response/ResponseValidationErrorModelTests.swift | 2 +- .../Auth/Repositories/Extensions/SequenceAsyncTests.swift | 4 ++-- .../Core/Platform/Utilities/AnyCodableTests.swift | 2 +- .../Extensions/URLSessionHTTPClientTests.swift | 6 +++--- Networking/Tests/NetworkingTests/HTTPRequestTests.swift | 6 +++--- Networking/Tests/NetworkingTests/HTTPResponseTests.swift | 6 +++--- Networking/Tests/NetworkingTests/RequestTests.swift | 2 +- Networking/Tests/NetworkingTests/ResponseTests.swift | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/BitwardenShared/Core/Auth/Models/Response/ErrorResponseModelTests.swift b/BitwardenShared/Core/Auth/Models/Response/ErrorResponseModelTests.swift index e2b6fa746..002a91f5b 100644 --- a/BitwardenShared/Core/Auth/Models/Response/ErrorResponseModelTests.swift +++ b/BitwardenShared/Core/Auth/Models/Response/ErrorResponseModelTests.swift @@ -6,7 +6,7 @@ import XCTest class ErrorResponseModelTests: BitwardenTestCase { /// Tests that `singleMessage()` returns the validation error's message. - func testSingleMessage() throws { + func test_singleMessage() throws { let json = APITestData.createAccountAccountAlreadyExists.data let decoder = JSONDecoder() let subject = try decoder.decode(ErrorResponseModel.self, from: json) @@ -14,7 +14,7 @@ class ErrorResponseModelTests: BitwardenTestCase { } /// Tests that `singleMessage()` returns an error message when there are no validation errors. - func testSingleMessageNilValidationErrors() throws { + func test_singleMessage_nilValidationErrors() throws { let json = APITestData.createAccountNilValidationErrors.data let decoder = JSONDecoder() let subject = try decoder.decode(ErrorResponseModel.self, from: json) diff --git a/BitwardenShared/Core/Auth/Models/Response/ResponseValidationErrorModelTests.swift b/BitwardenShared/Core/Auth/Models/Response/ResponseValidationErrorModelTests.swift index 9701f373c..0bfd3f817 100644 --- a/BitwardenShared/Core/Auth/Models/Response/ResponseValidationErrorModelTests.swift +++ b/BitwardenShared/Core/Auth/Models/Response/ResponseValidationErrorModelTests.swift @@ -8,7 +8,7 @@ class ResponseValidationErrorModelTests: BitwardenTestCase { // MARK: - Tests /// Tests that a response is initialized correctly. - func testInit() { + func test_init() { let subject = ResponseValidationErrorModel( error: "invalid_input", errorDescription: "invalid_username", diff --git a/BitwardenShared/Core/Auth/Repositories/Extensions/SequenceAsyncTests.swift b/BitwardenShared/Core/Auth/Repositories/Extensions/SequenceAsyncTests.swift index c3e29f0a4..d10d8bef9 100644 --- a/BitwardenShared/Core/Auth/Repositories/Extensions/SequenceAsyncTests.swift +++ b/BitwardenShared/Core/Auth/Repositories/Extensions/SequenceAsyncTests.swift @@ -4,7 +4,7 @@ import XCTest final class SequenceAsyncTests: BitwardenTestCase { /// `asyncMap` correctly maps each element. - func testAsyncMapSuccess() async { + func test_asyncMap_success() async { let input = [1, 2, 3] let output = await input.asyncMap { number in await asyncDouble(number) @@ -13,7 +13,7 @@ final class SequenceAsyncTests: BitwardenTestCase { } /// `asyncMap` correctly propagates errors. - func testAsyncMapWithError() async { + func test_asyncMap_error() async { let input = [1, 2, 3] await assertAsyncThrows { _ = try await input.asyncMap { number in diff --git a/BitwardenShared/Core/Platform/Utilities/AnyCodableTests.swift b/BitwardenShared/Core/Platform/Utilities/AnyCodableTests.swift index 9b7b597bc..891c23cd8 100644 --- a/BitwardenShared/Core/Platform/Utilities/AnyCodableTests.swift +++ b/BitwardenShared/Core/Platform/Utilities/AnyCodableTests.swift @@ -50,7 +50,7 @@ class AnyCodableTests: BitwardenTestCase { } /// `AnyCodable` can be used to encode JSON. - func testEncode() throws { + func test_encode() throws { let dictionary: [String: AnyCodable] = [ "minComplexity": AnyCodable.null, "minLength": AnyCodable.int(12), diff --git a/Networking/Tests/NetworkingTests/Extensions/URLSessionHTTPClientTests.swift b/Networking/Tests/NetworkingTests/Extensions/URLSessionHTTPClientTests.swift index 68f00ca6f..d5dff02b6 100644 --- a/Networking/Tests/NetworkingTests/Extensions/URLSessionHTTPClientTests.swift +++ b/Networking/Tests/NetworkingTests/Extensions/URLSessionHTTPClientTests.swift @@ -22,7 +22,7 @@ class URLSessionHTTPClientTests: XCTestCase { } /// `send(_:)` performs the request and returns the response for a 200 status request. - func testSendSuccess200() async throws { + func test_send_success200() async throws { let urlResponse = HTTPURLResponse( url: URL(string: "https://example.com")!, statusCode: 200, @@ -47,7 +47,7 @@ class URLSessionHTTPClientTests: XCTestCase { } /// `send(_:)` performs the request and returns the response for a 500 status request. - func testSendSuccess500() async throws { + func test_send_success500() async throws { let urlResponse = HTTPURLResponse( url: URL(string: "https://example.com")!, statusCode: 500, @@ -69,7 +69,7 @@ class URLSessionHTTPClientTests: XCTestCase { } /// `send(_:)` performs the request and throws an error if one occurs. - func testSendError() async throws { + func test_send_error() async throws { URLProtocolMocking.mock( HTTPRequest.default.url, with: .failure(NSError(domain: NSURLErrorDomain, code: NSURLErrorTimedOut, userInfo: nil)) diff --git a/Networking/Tests/NetworkingTests/HTTPRequestTests.swift b/Networking/Tests/NetworkingTests/HTTPRequestTests.swift index 6265ebc77..77e081292 100644 --- a/Networking/Tests/NetworkingTests/HTTPRequestTests.swift +++ b/Networking/Tests/NetworkingTests/HTTPRequestTests.swift @@ -13,7 +13,7 @@ class HTTPRequestTests: XCTestCase { } /// The initializer provides default values. - func testInitDefaultValues() { + func test_init_defaultValues() { let subject = HTTPRequest(url: URL(string: "https://example.com")!) XCTAssertNil(subject.body) @@ -23,7 +23,7 @@ class HTTPRequestTests: XCTestCase { } /// The initializer sets the item's properties. - func testInit() throws { + func test_init() throws { let subject = HTTPRequest( url: URL(string: "https://example.com/json")!, method: .post, @@ -50,7 +50,7 @@ class HTTPRequestTests: XCTestCase { } /// `init(request:baseURL)` builds a `HTTPRequest` from a `Request` object. - func testInitRequest() throws { + func test_init_request() throws { let subject = try HTTPRequest( request: TestRequest(), baseURL: URL(string: "https://example.com/")! diff --git a/Networking/Tests/NetworkingTests/HTTPResponseTests.swift b/Networking/Tests/NetworkingTests/HTTPResponseTests.swift index 4daef4c55..c2abfb7b0 100644 --- a/Networking/Tests/NetworkingTests/HTTPResponseTests.swift +++ b/Networking/Tests/NetworkingTests/HTTPResponseTests.swift @@ -4,7 +4,7 @@ import XCTest class HTTPResponseTests: XCTestCase { /// The initializer sets the item's properties. - func testInit() { + func test_init() { let subject = HTTPResponse( url: URL(string: "https://example.com")!, statusCode: 200, @@ -20,7 +20,7 @@ class HTTPResponseTests: XCTestCase { } /// The initializer sets the item's properties with a `HTTPURLResponse`. - func testInitResponse() throws { + func test_init_httpUrlResponse() throws { let subject = try HTTPResponse( data: "response body".data(using: .utf8)!, response: XCTUnwrap(HTTPURLResponse( @@ -42,7 +42,7 @@ class HTTPResponseTests: XCTestCase { } /// Initializing an `HTTPResponse` with an `URLResponse` vs a `HTTPURLResponse` throws an error. - func testInitWithURLResponseThrowsError() { + func test_init_urlResponse_error() { let urlResponse = URLResponse( url: URL(string: "https://example.com")!, mimeType: nil, diff --git a/Networking/Tests/NetworkingTests/RequestTests.swift b/Networking/Tests/NetworkingTests/RequestTests.swift index e28e6f44a..d1b5254e8 100644 --- a/Networking/Tests/NetworkingTests/RequestTests.swift +++ b/Networking/Tests/NetworkingTests/RequestTests.swift @@ -9,7 +9,7 @@ class RequestTests: XCTestCase { } /// `Request` default. - func testRequest() { + func test_request() { let request = DefaultRequest() XCTAssertEqual(request.method, .get) XCTAssertNil(request.body) diff --git a/Networking/Tests/NetworkingTests/ResponseTests.swift b/Networking/Tests/NetworkingTests/ResponseTests.swift index 88d271cbe..9bf231012 100644 --- a/Networking/Tests/NetworkingTests/ResponseTests.swift +++ b/Networking/Tests/NetworkingTests/ResponseTests.swift @@ -4,7 +4,7 @@ import XCTest class ResponseTests: XCTestCase { /// Test creating a `Response` from JSON. - func testJSONResponse() throws { + func test_jsonresponse() throws { let httpResponse = HTTPResponse( url: URL(string: "http://example.com")!, statusCode: 200, @@ -17,7 +17,7 @@ class ResponseTests: XCTestCase { } /// Test creating a `Response` from a JSON array. - func testJSONArray() throws { + func test_jsonresponse_array() throws { let httpResponse = HTTPResponse( url: URL(string: "http://example.com")!, statusCode: 200,