joao-r-reis commented on code in PR #1929:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1929#discussion_r2932371518


##########
cassandra_test.go:
##########
@@ -4397,3 +4405,28 @@ func TestHostInfoFromIter(t *testing.T) {
                t.Errorf("unexpected non-missing rack")
        }
 }
+
+type mockSessionReadyListener struct {
+       readyCount int
+}
+
+func (l *mockSessionReadyListener) OnSessionReady() {
+       l.readyCount++
+}
+
+func TestSessionReadyEvent(t *testing.T) {
+       listener := &mockSessionReadyListener{}
+
+       // Don't use createSession helper because it creates session twice,
+       // once for creating test keyspace and once for the session itself
+       cluster := createCluster()
+       cluster.Metadata.SessionReadyListener = listener
+       session, err := cluster.CreateSession()
+       require.NoError(t, err)
+       defer session.Close()
+
+       require.Eventually(t, func() bool {
+               require.Equal(t, 1, listener.readyCount)
+               return true
+       }, time.Second*5, time.Millisecond*100, "Expected session ready event 
to be received")
+}

Review Comment:
   move `require.Equal(t, 1, listener.readyCount)` here after the `Eventually` 
call just to make sure the counter didn't increase after the `== 1` condition 
succeded.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to