Skip to content

Commit

Permalink
Add new URLRequest validation methods to URLMock (#43)
Browse files Browse the repository at this point in the history
* #42: Add new URLRequest validation methods to URLMock

* #42: Update URLMock documentation
  • Loading branch information
tdeleon authored Jan 24, 2024
1 parent 2836e1a commit c8619b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 0 additions & 4 deletions Sources/Relax/API Structure/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ extension Endpoint {
public static var baseURL: URL {
Parent.baseURL.appendingPathComponent(path)
}

// public static var configuration: Request.Configuration {
// Parent.configuration
// }
}
6 changes: 6 additions & 0 deletions Sources/URLMock/URLMock.docc/URLRequest+Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ the request received is correct.
- ``Foundation/URLRequest/validateBody(matches:)-9rwxp``
- ``Foundation/URLRequest/validateBody(matches:decoder:)``
- ``Foundation/URLRequest/validateBody(matches:)-5ihb5``

### Validating Request Path
- ``Foundation/URLRequest/validate(path:)``

### Validating Request HTTP Method
- ``Foundation/URLRequest/validate(httpMethod:)``
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// RequestValidation.swift
// URLRequestValidation.swift
//
//
// Created by Thomas De Leon on 11/29/23.
Expand Down Expand Up @@ -139,4 +139,16 @@ extension URLRequest {
XCTAssertTrue(names.isSuperset(of: contain))
XCTAssertTrue(names.intersection(doNotContain).isEmpty)
}

/// Validate the path of the request
/// - Parameter path: The path to match
public func validate(path: String) {
XCTAssertEqual(urlComponents?.path, path)
}

/// Validate the request HTTP
/// - Parameter httpMethod: The http method string to match. If nil is provided, the request should have nil for the http method
public func validate(httpMethod: String?) {
XCTAssertEqual(self.httpMethod, httpMethod)
}
}

0 comments on commit c8619b1

Please sign in to comment.