Skip to content

Commit

Permalink
Refactored test assertions with expected and actual at right places
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jul 25, 2024
1 parent 5891b9c commit 8345e42
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ably/realtime_presence_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func TestRealtimePresence_Presence_Enter_Update_Leave(t *testing.T) {
member_received := <-subCh1
assert.Len(t, subCh1, 0) // Ensure no more updates received

assert.Equal(t, member_received.Action, ably.PresenceActionEnter)
assert.Equal(t, member_received.ClientID, "client2")
assert.Equal(t, member_received.Data, "enter client2")
assert.Equal(t, ably.PresenceActionEnter, member_received.Action)
assert.Equal(t, "client2", member_received.ClientID)
assert.Equal(t, "enter client2", member_received.Data)

// UPDATE
err = channel2.Presence.Update(context.Background(), "update client2")
Expand All @@ -183,9 +183,9 @@ func TestRealtimePresence_Presence_Enter_Update_Leave(t *testing.T) {
member_received = <-subCh1
assert.Len(t, subCh1, 0) // Ensure no more updates received

assert.Equal(t, member_received.Action, ably.PresenceActionUpdate)
assert.Equal(t, member_received.ClientID, "client2")
assert.Equal(t, member_received.Data, "update client2")
assert.Equal(t, ably.PresenceActionUpdate, member_received.Action)
assert.Equal(t, "client2", member_received.ClientID)
assert.Equal(t, "update client2", member_received.Data)

// LEAVE
err = channel2.Presence.Leave(context.Background(), "leave client2")
Expand All @@ -194,9 +194,9 @@ func TestRealtimePresence_Presence_Enter_Update_Leave(t *testing.T) {
member_received = <-subCh1
assert.Len(t, subCh1, 0) // Ensure no more updates received

assert.Equal(t, member_received.Action, ably.PresenceActionLeave)
assert.Equal(t, member_received.ClientID, "client2")
assert.Equal(t, member_received.Data, "leave client2")
assert.Equal(t, ably.PresenceActionLeave, member_received.Action)
assert.Equal(t, "client2", member_received.ClientID)
assert.Equal(t, "leave client2", member_received.Data)
}

func TestRealtimePresence_ServerSynthesized_Leave(t *testing.T) {
Expand Down Expand Up @@ -231,9 +231,9 @@ func TestRealtimePresence_ServerSynthesized_Leave(t *testing.T) {

member_received := <-subCh1
assert.Len(t, subCh1, 0) // Ensure no more updates received
assert.Equal(t, member_received.Action, ably.PresenceActionEnter)
assert.Equal(t, member_received.ClientID, "client2")
assert.Equal(t, member_received.Data, "enter client2")
assert.Equal(t, ably.PresenceActionEnter, member_received.Action)
assert.Equal(t, "client2", member_received.ClientID)
assert.Equal(t, "enter client2", member_received.Data)

members, err := client1Channel.Presence.Get(context.Background())
assert.NoError(t, err)
Expand All @@ -245,8 +245,8 @@ func TestRealtimePresence_ServerSynthesized_Leave(t *testing.T) {
member_received = <-subCh1
assert.Len(t, subCh1, 0) // Ensure no more updates received

assert.Equal(t, member_received.Action, ably.PresenceActionLeave)
assert.Equal(t, member_received.ClientID, "client2")
assert.Equal(t, ably.PresenceActionLeave, member_received.Action)
assert.Equal(t, "client2", member_received.ClientID)

// Make sure no members are present on the channel
members, err = client1Channel.Presence.Get(context.Background())
Expand Down

0 comments on commit 8345e42

Please sign in to comment.