Skip to content

Commit

Permalink
added test for host unresolvable or unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Jan 19, 2024
1 parent 64bc85b commit a024bb4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ably/rest_client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,27 @@ func TestRest_RSC15_HostFallback(t *testing.T) {
assertUnique(t, hosts) // ensure all picked fallbacks are unique
})

t.Run("RSC15l1 must use alternative host on host unresolvable or unreachable", func(t *testing.T) {
options := []ably.ClientOption{
ably.WithFallbackHosts(ably.DefaultFallbackHosts()),
ably.WithRESTHost("foobar.ably.com"),
ably.WithFallbackHosts([]string{
"spam.ably.com",
"tatto.ably.com",
"rest.ably.io"}),
ably.WithTLS(false),
ably.WithUseTokenAuth(true),
}
client, err := ably.NewREST(app.Options(options...)...)
assert.NoError(t, err)
tm, err := client.Time(context.Background())
assert.Nil(t, err)
assert.NotNil(t, tm)
time.Sleep(2 * time.Second)
cachedFallbackHost := client.GetCachedFallbackHost()
assert.Equal(t, "rest.ably.io", cachedFallbackHost)
})

t.Run("rsc15b", func(t *testing.T) {
t.Run("must not occur when default rest.ably.io is overridden", func(t *testing.T) {

Expand Down

0 comments on commit a024bb4

Please sign in to comment.