Skip to content
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

Merged
merged 13 commits into from
Oct 3, 2023
Merged

Add collections-related test suite #38

merged 13 commits into from
Oct 3, 2023

Conversation

AngeloStavrow
Copy link
Collaborator

@AngeloStavrow AngeloStavrow commented Apr 9, 2023

This PR closes #4, adding tests for collection-related endpoints.

@AngeloStavrow AngeloStavrow self-assigned this Apr 9, 2023
@AngeloStavrow AngeloStavrow changed the title Add initial test suite Add collections-related test suite Jul 16, 2023
Comment on lines +31 to +33
resources: [
.process("Resources")
]
Copy link
Collaborator Author

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
Copy link
Collaborator Author

@AngeloStavrow AngeloStavrow Jul 16, 2023

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? {
Copy link
Collaborator Author

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.

Comment on lines +5 to +12
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)
]
Copy link
Collaborator Author

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.

Copy link
Member

@thebaer thebaer left a 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!

@AngeloStavrow AngeloStavrow merged commit 4919bb1 into main Oct 3, 2023
@AngeloStavrow AngeloStavrow deleted the 4_add-test-suite branch December 27, 2023 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add test suite for collections-related methods
2 participants