Skip to content

Commit

Permalink
Added test for checking active internet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Aug 7, 2024
1 parent a5964df commit ef8bcee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
4 changes: 4 additions & 0 deletions ably/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func (opts *clientOptions) GetFallbackRetryTimeout() time.Duration {
return opts.fallbackRetryTimeout()
}

func (opts *clientOptions) HasActiveInternetConnection() bool {
return opts.hasActiveInternetConnection()
}

func NewErrorInfo(code ErrorCode, err error) *ErrorInfo {
return newError(code, err)
}
Expand Down
46 changes: 24 additions & 22 deletions ably/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,33 @@ import (
)

func TestDefaultFallbacks_RSC15h(t *testing.T) {
t.Run("with env should return environment fallback hosts", func(t *testing.T) {
expectedFallBackHosts := []string{
"a.ably-realtime.com",
"b.ably-realtime.com",
"c.ably-realtime.com",
"d.ably-realtime.com",
"e.ably-realtime.com",
}
hosts := ably.DefaultFallbackHosts()
assert.Equal(t, expectedFallBackHosts, hosts)
})
expectedFallBackHosts := []string{
"a.ably-realtime.com",
"b.ably-realtime.com",
"c.ably-realtime.com",
"d.ably-realtime.com",
"e.ably-realtime.com",
}
hosts := ably.DefaultFallbackHosts()
assert.Equal(t, expectedFallBackHosts, hosts)
}

func TestEnvFallbackHosts_RSC15i(t *testing.T) {
t.Run("with env should return environment fallback hosts", func(t *testing.T) {
expectedFallBackHosts := []string{
"sandbox-a-fallback.ably-realtime.com",
"sandbox-b-fallback.ably-realtime.com",
"sandbox-c-fallback.ably-realtime.com",
"sandbox-d-fallback.ably-realtime.com",
"sandbox-e-fallback.ably-realtime.com",
}
hosts := ably.GetEnvFallbackHosts("sandbox")
assert.Equal(t, expectedFallBackHosts, hosts)
})
expectedFallBackHosts := []string{
"sandbox-a-fallback.ably-realtime.com",
"sandbox-b-fallback.ably-realtime.com",
"sandbox-c-fallback.ably-realtime.com",
"sandbox-d-fallback.ably-realtime.com",
"sandbox-e-fallback.ably-realtime.com",
}
hosts := ably.GetEnvFallbackHosts("sandbox")
assert.Equal(t, expectedFallBackHosts, hosts)
}

func TestInternetConnectionCheck_RTN17c(t *testing.T) {
t.Parallel()
clientOptions := ably.NewClientOptions()
assert.True(t, clientOptions.HasActiveInternetConnection())
}

func TestFallbackHosts_RSC15b(t *testing.T) {
Expand Down

0 comments on commit ef8bcee

Please sign in to comment.