Skip to content
Merged
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions integration/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -830,4 +830,44 @@ def test_can_set_protocol_version_explicitly
cluster && cluster.close
end

# Test for cluster and session object inspection
#
# test_cluster_session_inspect tests that cluster and session objects can be inspected, and their stored options can
# be retrieved in the inspect string. It first creates a simple cluster and session object with some options defined.
# It then inspects these objects and verifies that the options set are visible in the inspect string.
#
# @since 3.0.0
# @jira_ticket RUBY-162
# @expected_result cluster and object options should be visible in the inspect string
#
# @test_category connection
#
def test_cluster_session_inspect
cluster = Cassandra.cluster(hosts: ['127.0.0.1'], consistency: :quorum, page_size: 10)
session = cluster.connect('simplex')

cluster_inspect = cluster.inspect
assert_match(/name="ruby-driver-.*"/, cluster_inspect)
assert_match(/hosts=\[.* @ip=127\.0\.0\.1>\]/, cluster_inspect)
assert_match(/port=9042/, cluster_inspect)
assert_match(/protocol_version=[1-4]/, cluster_inspect)
assert_match(/keyspaces=\[.* @name=simplex>\]/, cluster_inspect)
assert_match(/load_balancing_policy=#<Cassandra::LoadBalancing::Policies::TokenAware.*\
policy=#<Cassandra::LoadBalancing::Policies::DCAwareRoundRobin.*\
datacenter="datacenter1", use_remote=false, max_remote=0.*shuffle=true/, cluster_inspect)
assert_match(/consistency=:quorum/, cluster_inspect)
assert_match(/timeout=12/, cluster_inspect)

session_inspect = session.inspect
assert_match(/@keyspace="simplex"/, session_inspect)
assert_match(/@consistency=:quorum/, session_inspect)
assert_match(/@page_size=10/, session_inspect)
assert_match(/@trace=false/, session_inspect)
assert_match(/@timeout=12/, session_inspect)
assert_match(/@serial_consistency=nil/, session_inspect)
assert_match(/@paging_state=nil/, session_inspect)
assert_match(/@idempotent=false/, session_inspect)
assert_match(/@payload=nil/, session_inspect)
end

end