-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add collections-related test suite #38
Conversation
Signed-off-by: Angelo Stavrow <[email protected]>
Signed-off-by: Angelo Stavrow <[email protected]>
Signed-off-by: Angelo Stavrow <[email protected]>
resources: [ | ||
.process("Resources") | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets us use the test JSON files under Tests/WriteFreelyTests/Resources
.
var nextDataTask = MockURLSessionDataTask() | ||
var nextData: Data? | ||
var nextError: Error? | ||
var expectedStatusCode: Int = 200 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets us set our expected status code explicitly in our tests — not everything expects a 200 OK
!
} | ||
|
||
@discardableResult | ||
func setData(resource: String, fileExt: String, for target: XCTestCase) throws -> URL? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this to set the response JSON from a file in our Resources
path.
static var allTests = [ | ||
("testCreateCollection_WithValidCollectionData_CreatesNewWFCollection", testCreateCollection_WithValidCollectionData_CreatesNewWFCollection), | ||
("testCreateCollection_WithInvalidCollectionData_ReturnsBadRequestError", testCreateCollection_WithInvalidCollectionData_ReturnsBadRequestError), | ||
("testGetCollection_WithValidCollectionData_RetrievesCollectionMetadata", testGetCollection_WithValidCollectionData_RetrievesCollectionMetadata), | ||
("testGetCollection_WithInvalidCollectionData_ReturnsInvalidDataError", testGetCollection_WithInvalidCollectionData_ReturnsInvalidDataError), | ||
("testDeleteCollection_WithValidCollectionAlias_ReturnsTrue", testDeleteCollection_WithValidCollectionAlias_ReturnsTrue), | ||
("testDeleteCollection_WithInvalidCollectionAlias_ReturnsInvalidResponseError", testDeleteCollection_WithInvalidCollectionAlias_ReturnsInvalidResponseError) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We focus here on the createCollection
, getCollection
, and deleteCollection
methods on WFClient as "collection"-related methods.
The REST API includes things like getting a post from a collection, for example, but in the client we make that a "post"-related method as an overload on getPost
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
This PR closes #4, adding tests for collection-related endpoints.