-
Notifications
You must be signed in to change notification settings - Fork 24
Add integration tests #209
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
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
parfeon
left a comment
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.
It looks good. I've left few notes about tests, where we removing / adding something and actually don't verify that operation actually performed this modification (not just success status).
| final class ChannelGroupEndpointIntegrationTests: XCTestCase { | ||
| let config = PubNubConfiguration(from: Bundle(for: ChannelGroupEndpointIntegrationTests.self)) | ||
|
|
||
| func testListChannelGroups() { |
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 test is a bit fragile because depends on the current situation with keys, where bunch of channel groups has been created. There is a chance that they will be wiped one day and this test will make false result.
Or it will be fine even if there is just empty array? Should we create in this test at least one channel group which will be pulled and then at the end remove it?
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.
Let's remove this test according to the docs statement at the top:
https://www.pubnub.com/docs/sdks/rest-api/get-all-channel-groups
| XCTAssertEqual(response.group, testGroup) | ||
| XCTAssertEqual(Set(response.channels), Set(testChannels)) |
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 information added by SDK itself and not from response? I tried to make a request to self-check and there is no information about group and added channels.
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.
Yes, this information is added by the SDK itself:
https://github.com/pubnub/swift/blob/refactor/integration-tests/Sources/PubNub/PubNub.swift#L915
On a successful response, it returns the list of channels and channel groups that were passed as arguments
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.
Ok. I hope it won't hit us back that users will miss same behaviour in other languages :D
| wait(for: [listChannelsExpect], timeout: 10.0) | ||
| } | ||
|
|
||
| func testAddChannelsToGroup() { |
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.
Should we actually validate that channels has been added to the channel group (using listChannels)?
| wait(for: [addChannelsExpect], timeout: 10.0) | ||
| } | ||
|
|
||
| func testRemoveChannelsFromGroup() { |
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.
Should we actually validate that channels has been removed from the channel group (using listChannels)?
| wait(for: [removeChannelsExpect], timeout: 10.0) | ||
| } | ||
|
|
||
| func testRemoveChannelGroup() { |
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.
Should we actually validate that channel groups has been removed (using listChannelGroups)?
| client.allChannelMetadata(sort: [.init(property: .name)]) { result in | ||
| let expectedChannels = setupTestChannels(client: client) | ||
|
|
||
| client.allChannelMetadata(filter: "id LIKE 'swift-*'") { result in |
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.
Nice solution with filtering.
Same concerns about how it could be fragile without pre-populated data.
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.
Unfortunately, there's no other choice than pre-populating channel/user metadata first before testing whether fetching all of them works as expected
No description provided.