Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldNordgren committed Sep 27, 2024
1 parent 406a97f commit 5a3faab
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions internal/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestMutation(t *testing.T) {
require.Errorf(t, err, "client does not support mutations")
}

type subscriptionCountResult struct {
type subscriptionResult struct {
clientUnsubscribed bool
serverChannelClosed bool
}
Expand All @@ -67,35 +67,34 @@ func TestSubscription(t *testing.T) {
subscription count { count }`

ctx := context.Background()
server := server.RunServer()
defer server.Close()

cases := []struct {
name string
unsubThreshold time.Duration
expected subscriptionCountResult
expected subscriptionResult
}{
{
name: "client_unsubscribed",
unsubThreshold: 300 * time.Millisecond,
expected: subscriptionCountResult{
clientUnsubscribed: true,
serverChannelClosed: false,
},
},
{
name: "server_closed_channel",
unsubThreshold: 5 * time.Second,
expected: subscriptionCountResult{
expected: subscriptionResult{
clientUnsubscribed: false,
serverChannelClosed: true,
},
},
{
name: "client_unsubscribed",
unsubThreshold: 300 * time.Millisecond,
expected: subscriptionResult{
clientUnsubscribed: true,
serverChannelClosed: false,
},
},
}

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
server := server.RunServer()
defer server.Close()

wsClient := newRoundtripWebSocketClient(t, server.URL)
errChan, err := wsClient.Start(ctx)
require.NoError(t, err)
Expand All @@ -107,7 +106,7 @@ func TestSubscription(t *testing.T) {
var (
counter = 0
start = time.Now()
result = subscriptionCountResult{}
result = subscriptionResult{}
)

for loop := true; loop; {
Expand Down

0 comments on commit 5a3faab

Please sign in to comment.