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

Getting the test suite in shape to match the phoenix js one #4

Merged
merged 153 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
555e378
Skip the failing join/leave event test for now
myobie Jan 19, 2020
51ce06f
Don’t ever send a completion through the Socket subject
myobie Jan 19, 2020
9f81d9d
Implement init and connection tests for Socket
myobie Jan 19, 2020
fa667c6
Rename connection related functions and messages
myobie Jan 19, 2020
e3630ad
Rename test to indicate scope
myobie Jan 19, 2020
37c68a6
Socket doesn’t connect on init
myobie Jan 19, 2020
a99a767
Socket state now conforms to the same names and principles as the js
myobie Jan 19, 2020
fd60e93
Socket can produce channels
myobie Jan 19, 2020
22c590e
Can join a channel even if disconnected and can push directly onto an…
myobie Jan 26, 2020
e3db066
Socket has a pending buffer
myobie Jan 26, 2020
e7f2995
Restart refs after the maximum safe integer for Javascript
myobie Jan 26, 2020
3189da1
Wait longer for the server to start in CI
myobie Jan 26, 2020
9693af9
Fixup the ref and ref tests to link to the docs for why
myobie Jan 26, 2020
ae15517
Heartbeat tests
myobie Jan 26, 2020
c73462c
Flushes pending in socket on open
myobie Jan 26, 2020
3e1e598
Build a quick javascript socket page for testing
myobie Jan 26, 2020
54d1a97
Channels now error when the socket closes from the server-side
myobie Jan 26, 2020
a013988
Skip a channel test for now until I make it to the Channel section of…
myobie Jan 27, 2020
786dff0
Test to not error a channel that explicitly left if the remote closes
myobie Jan 27, 2020
9860a12
Update dependencies for the test phoenix app
myobie Jan 27, 2020
647b039
Found a way to have a socket level message and using it for disconnec…
myobie Jan 27, 2020
f278e98
Remove all uses of the soon query param from the Socket tests
myobie Jan 27, 2020
a3e0f58
Explain the custom socket command for disconnecting
myobie Jan 27, 2020
567abcd
Fix a bug where a channel doesn’t flush right after joining
myobie Jan 27, 2020
8833468
Final tests for Socket
myobie Jan 27, 2020
c09fce0
Make Socket a ConnectablePublisher
myobie Feb 6, 2020
cf95613
Prettify SocketTests
myobie Feb 8, 2020
c50eed1
Unskip test
myobie Feb 8, 2020
ef26b3b
Completely seperate subscriber and publisher typealiases
myobie Feb 8, 2020
1106aa6
Remove Result from Channel and add error to Channel.Event
myobie Feb 8, 2020
4f6ca57
Cleanup channel test a bit
myobie Feb 8, 2020
4a71c0c
Beginning the ChannelTests comformation with the js
myobie Feb 9, 2020
7a5d40a
Channel is joining after push
myobie Feb 9, 2020
4e05b1a
No longer need the “disconnect soon” connection params in UserSocket …
myobie Feb 10, 2020
5d4722a
Joining twice is a no-op
myobie Feb 10, 2020
2681518
Can confirm join params make it to the server
myobie Feb 10, 2020
19a5a06
Can have a custom join timeout for a channel
myobie Feb 10, 2020
864f6fd
Skip old tests
myobie Feb 10, 2020
9724e67
Begining of timeout tests
myobie Feb 10, 2020
84f5294
Extract all enums, structs, and classes each to their own file
myobie Feb 11, 2020
80b7ce2
Fix unused variable in example elixir app
myobie Feb 11, 2020
6dfd1a8
Call completion handler on send if could not serialize outgoing message
myobie Feb 11, 2020
615fe21
Go ahead and mark as closing so the next send fails immediately
myobie Feb 11, 2020
2acc15e
Forgot the Error case
myobie Feb 11, 2020
552d4b9
joinPayload doesn’t need to be public
myobie Feb 11, 2020
7dff231
Need to set the state to closing for failures in both send methods
myobie Feb 11, 2020
d177ed9
Add tolerance to the heartbeat timer for niceness
myobie Feb 11, 2020
c670829
Call completion handlers after state is updated
myobie Feb 11, 2020
ce03683
Remove unused function
myobie Feb 11, 2020
b7cf582
Uh, this flush stuff is overly complicated for no good reason
myobie Feb 11, 2020
fe31d42
Reformat this code to match whats below
myobie Feb 11, 2020
acc6079
Re-arrange order of events for heartbeat timeout
myobie Feb 12, 2020
c11661c
Socket init doesn’t need to throw, Channel now subscribes to all Sock…
myobie Feb 12, 2020
1f7a3a8
Only accept a join reply if it’s an ok status
myobie Feb 13, 2020
e4b8a38
Handle socket open and close for all the channel states
myobie Feb 13, 2020
97553a3
All tests pass now except for the channel join timeout one, which is …
myobie Feb 13, 2020
fa57f56
Organize channel methods a bit before adding new timeout code
myobie Feb 13, 2020
2eccb70
Timers suck, I’ll remove them soon
myobie Feb 13, 2020
424fbb2
OK, let’s try to make my own expectation framework
myobie Feb 14, 2020
e6ecd24
OK, my own wait and Expectation works well enough to move forward
myobie Feb 14, 2020
5a27c9b
Move this var up
myobie Feb 14, 2020
ca634b3
It doesn’t work
myobie Feb 14, 2020
72f4302
Remove custom test framework
myobie Feb 16, 2020
e4c8c1f
Use the new Timer which uses DispatchSourceTimer
myobie Feb 16, 2020
12754a4
Channel join timeout and backoff works
myobie Feb 16, 2020
56b992c
Uncomment old tests as they now work again 🙌🏻
myobie Feb 16, 2020
86e83ee
Rename example to server
atdrendel Jun 2, 2020
c7fdf9d
Add a helper script to run the server and add information about runni…
atdrendel Jun 2, 2020
cad203a
Update GitHub Action
atdrendel Jun 2, 2020
661f5f4
Add link to available macOS environments
atdrendel Jun 2, 2020
616278c
Update path to Phoenix server
atdrendel Jun 2, 2020
ba80be2
Rename Example to Server
atdrendel Jun 4, 2020
cded0e3
Replace Channel rejoin timeout with a function
atdrendel Jun 4, 2020
c214393
Whitespace
atdrendel Jun 4, 2020
0fe6fd2
Fix spelling mistake
atdrendel Jun 4, 2020
8ca75d9
Modify timeouts
atdrendel Jun 4, 2020
38975f8
Fix warning
atdrendel Jun 4, 2020
4df834f
Reduce running time of ChannelTests
atdrendel Jun 4, 2020
3d8fa08
Extract asserting on open in SocketTests
atdrendel Jun 4, 2020
e62000f
Follow example set by Starscream
atdrendel Jun 6, 2020
5d49ad1
Add RawCaseConvertible
atdrendel Jun 6, 2020
ab09514
Add more test helpers to SocketTests
atdrendel Jun 6, 2020
6d5dbfb
Add a couple tests to illustrate differences of the autoconnect subsc…
myobie Jun 7, 2020
a7eeb4a
Simplify SocketTests
atdrendel Jun 7, 2020
973513f
Update comment in ChannelTests
atdrendel Jun 7, 2020
520dd43
Set .connecting state before sending .connecting message
atdrendel Jun 7, 2020
9f61a47
Disconnect when Socket deinits
atdrendel Jun 7, 2020
f9c78ca
Set .connecting state when connecting WebSocket
atdrendel Jun 7, 2020
a096d8a
Fix two tests to be less flaky
myobie Jun 7, 2020
7238322
Make sure the channels in a test are retained for the entire test
myobie Jun 7, 2020
da7b0e1
Extend timeout for CI for testJoinRetriesWithBackoffIfTimeout
myobie Jun 7, 2020
8dfa915
Add SocketTests.testSocketIsClosed()
atdrendel Jun 7, 2020
bb6ca11
Add link to JavaScript test
atdrendel Jun 7, 2020
3bf8729
Start adding socket test coverage
atdrendel Jun 7, 2020
6352840
Update server dependencies
atdrendel Jun 7, 2020
f78eefa
Fix Phoenix.PubSub warning
atdrendel Jun 7, 2020
01d98a5
Improve readability of testSocketAutoconnectSubscriberCancelDisconnec…
atdrendel Jun 7, 2020
c0ab5c3
Fix whitespace
atdrendel Jun 7, 2020
ba2865f
Fix WebSocket leak
atdrendel Jun 7, 2020
b3cbaad
Make WebSocket.delegateQueue serial
atdrendel Jun 7, 2020
d510cd6
Remove SimplePublisher
atdrendel Jun 8, 2020
933b6d1
Add some additional socket tests
atdrendel Jun 9, 2020
9bfcff7
Make WebSocket delegate queue serial
atdrendel Jun 10, 2020
05d9b52
Simplify public interface of Socket
atdrendel Jun 10, 2020
a57ae8d
Continue working on SocketTests
atdrendel Jun 10, 2020
a47858d
Upgrade broken plug_cowboy
atdrendel Jun 12, 2020
55d93b3
Continue adding and improving SocketTests
atdrendel Jun 12, 2020
1466a0a
Remove ineffective “boom” command from user_socket
atdrendel Jun 12, 2020
4b41951
Re-add “boom” handling in user_socket.ex
atdrendel Jun 13, 2020
6fa0c78
Implement socket reconnection logic and tests
atdrendel Jun 13, 2020
144f5cc
Make Channel’s background queue synchronous
atdrendel Jun 13, 2020
f5004ee
Remove global Ref.Generator and make Channel user Socket’s generator
atdrendel Jun 14, 2020
f199ecd
Add hacky XCTestCase.expectationWithTest()
atdrendel Jun 14, 2020
20c93d8
Make Socket.subject let instead of var
atdrendel Jun 14, 2020
d97ca21
Send all messages to Socket.subject on notifySubjectQueue
atdrendel Jun 14, 2020
aa887a2
Improve reliability of testSocketIsConnecting and testSocketIsClosing
atdrendel Jun 14, 2020
99da6aa
Move test helpers to XCTestCase+Phoenix
atdrendel Jun 15, 2020
e7e2a27
Rename ChannelJoinLeaveTimer to ChannelJoinTimer
atdrendel Jun 15, 2020
f53c76f
Remove Comparable conformance from PushedMessage and replace with Seq…
atdrendel Jun 15, 2020
18a088d
Simplify Channel.joinTimer
atdrendel Jun 15, 2020
41cd793
Improve reliability of testJoinRetriesWithBackoffIfTimeout()
atdrendel Jun 15, 2020
546a1be
Speed up SocketTests.testSocketIsConnectedEvenAfterSubscriptionIsCanc…
atdrendel Jun 15, 2020
5dbec51
Move test helpers to XCTestCase+Phoenix
atdrendel Jun 15, 2020
b97661b
Add Topic typealias
atdrendel Jun 17, 2020
0a9ea50
Upgrade to synchronized v2.0.0
atdrendel Jun 17, 2020
255e37a
Clean up comments and some Socket tests
atdrendel Jun 17, 2020
cb66133
Try to improve reliability of testJoinRetriesWithBackoffIfTimeout()
atdrendel Jun 17, 2020
641776b
Clean up tests
atdrendel Jun 17, 2020
57970e1
Clean up and add channel tests
atdrendel Jun 18, 2020
8636120
Add socket_test.js links to socket-test-coverage.md
atdrendel Jun 20, 2020
e527259
Remove unused Atomic
atdrendel Jun 21, 2020
af8c118
Add room:error Phoenix channel
atdrendel Jun 21, 2020
e34d3f9
Add more channel tests
atdrendel Jun 21, 2020
e70eece
Remove joinedOnce
atdrendel Jun 21, 2020
0b6fec6
Fix unreliable tests
atdrendel Jun 21, 2020
a8f803b
Add ChannelTests.testDoesNotSendAnyBufferedMessagesAfterJoinError()
atdrendel Jun 22, 2020
cf62dff
Fix expectError expectation name
atdrendel Jun 26, 2020
f4e3b28
Add onError channel tests
atdrendel Jun 26, 2020
fdf0d0b
Replace Forever in tests
atdrendel Jun 26, 2020
f010377
Remove Forever from phoenix-apple
atdrendel Jun 26, 2020
59968ff
Properly notify subscribers of Channel closing and remove channel fro…
atdrendel Jun 26, 2020
36c3683
Extract duplicated code into sendLeaveAndCompletionToSubjectAsync()
atdrendel Jun 27, 2020
8706647
Add start-phoenix-js command to test `phoenix-js`
atdrendel Jun 27, 2020
f258a5d
Add tests to channel-test-coverage.md
atdrendel Jun 27, 2020
93df0d8
Add more channel tests
atdrendel Jun 27, 2020
bba445b
Add more channel tests
atdrendel Jun 28, 2020
20958b3
Finish implementing all required tests for the channel
atdrendel Jun 30, 2020
6ed0c8c
Finish all leaving tests
atdrendel Jul 1, 2020
8cc0cf5
Clean up tests
atdrendel Jul 1, 2020
198c923
Try to fix ChannelTests.testJoinRetriesWithBackoffIfTimeout()
atdrendel Jul 1, 2020
3e68126
Try to fix ChannelTests.testJoinRetriesWithBackoffIfTimeout()
atdrendel Jul 1, 2020
07a39a0
Remove unnecessary print() statements
atdrendel Jul 1, 2020
c776506
Remove noisy print() statement
atdrendel Jul 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ name: ci
on: push
jobs:
test:
runs-on: macOS-10.14
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- name: Switch Xcode to 11.3
run: xcversion select 11.3
# Available environments: https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md#xcode
- name: Switch Xcode to 11.5
run: xcversion select 11.5
- name: Resolve package dependencies
run: swift package resolve
- name: Install elixir
Expand All @@ -15,16 +16,16 @@ jobs:
run: mix local.hex --force
- name: Install rebar3
run: mix local.rebar --force
- name: Get dependencies for example phoenix app
- name: Get dependencies for Phoenix app
run: mix deps.get
working-directory: ./Tests/PhoenixTests/example
- name: Build the example app
working-directory: ./Tests/PhoenixTests/server
- name: Build the server app
run: mix compile
working-directory: ./Tests/PhoenixTests/example
working-directory: ./Tests/PhoenixTests/server
- name: Test
run: |
cd Tests/PhoenixTests/example
cd Tests/PhoenixTests/server
( mix phx.server & )
cd -
sleep 1
sleep 7
swift test --skip-update
31 changes: 2 additions & 29 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
{
"object": {
"pins": [
{
"package": "Atomic",
"repositoryURL": "https://github.com/shareup/atomic.git",
"state": {
"branch": null,
"revision": "781438953ec4a7eec7d5467024a6d85423bc97b4",
"version": "1.0.1"
}
},
{
"package": "Forever",
"repositoryURL": "https://github.com/shareup/forever.git",
"state": {
"branch": null,
"revision": "2046d987986a43ae31c25f0e02ff9a2448cc45fb",
"version": "0.0.2"
}
},
{
"package": "SimplePublisher",
"repositoryURL": "https://github.com/shareup/simple-publisher.git",
"state": {
"branch": null,
"revision": "dd7809d44afb7e2becdc872e4f1c3ff3f537e1a6",
"version": "1.2.0"
}
},
{
"package": "Synchronized",
"repositoryURL": "https://github.com/shareup/synchronized.git",
"state": {
"branch": null,
"revision": "3084d4ac37ef2726058e990f62d1e1110862975d",
"version": "1.2.0"
"revision": "5f3312cf35cde0ddd1196ca9c44190b1859426e0",
"version": "2.0.0"
}
}
]
Expand Down
7 changes: 2 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ let package = Package(
targets: ["Phoenix"]),
],
dependencies: [
.package(url: "https://github.com/shareup/synchronized.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/shareup/forever.git", .upToNextMajor(from: "0.0.0")),
.package(url: "https://github.com/shareup/simple-publisher.git", .upToNextMajor(from: "1.2.0")),
.package(url: "https://github.com/shareup/atomic.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/shareup/synchronized.git", .upToNextMajor(from: "2.0.0")),
],
targets: [
.target(
name: "Phoenix",
dependencies: ["Atomic", "SimplePublisher", "Synchronized", "Forever"]),
dependencies: ["Synchronized"]),
.testTarget(
name: "PhoenixTests",
dependencies: ["Phoenix"]),
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# Phoenix channels client for Apple OS's

## _(macOS, iOS, iPadOS, tvOS, and watchOS)_

A package for connecting to and interacting with phoenix channels from Apple OS's written in Swift taking advantage of the built in `Websocket` support and `Combine` for publishing events to downstream consumers.

**Compatible with phoenix channels vsn=2.0.0 only.**

## Tests

### Using Xcode

1. In your Terminal, navigate to the `phoenix-apple` directory
2. Start the Phoenix server using `./start-server`
3. Open the `phoenix-apple` directory using Xcode
4. Make sure the build target is macOS
5. Product -> Test

### Using `swift test`

1. In your Terminal, navigate to the `phoenix-apple` directory
2. Start the Phoenix server using `./start-server`
3. Open the `phoenix-apple` directory in another Terminal window
4. Run the tests using `swift test`

## Running sample phoenix-js client

1. In your Terminal, navigate to the `phoenix-apple` directory
2. Start the Phoenix server using `./start-server`
3. In a new Terminal tab, navigate to the `phoenix-apple` directory
4. Start the `phoenix-js` cleint using `./start-phoenix-js`
5. Open the developer console in the just-opened Web browser window and send commands to the client using standard JavaScript
Loading