worryg0d commented on code in PR #1929:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1929#discussion_r2932277648


##########
schema_events_test.go:
##########
@@ -0,0 +1,444 @@
+//go:build cassandra
+// +build cassandra
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package gocql
+
+import (
+       "fmt"
+       "strings"
+       "testing"
+       "time"
+
+       "github.com/stretchr/testify/require"
+)
+
+type schemaChangesTestListener struct {
+       KeyspaceCreatedEvents []OnKeyspaceCreatedEvent
+       KeyspaceUpdatedEvents []OnKeyspaceUpdatedEvent
+       KeyspaceDroppedEvents []OnKeyspaceDroppedEvent
+
+       TableCreatedEvents []OnTableCreatedEvent
+       TableUpdatedEvents []OnTableUpdatedEvent
+       TableDroppedEvents []OnTableDroppedEvent
+
+       FunctionCreatedEvents []OnFunctionCreatedEvent
+       FunctionUpdatedEvents []OnFunctionUpdatedEvent
+       FunctionDroppedEvents []OnFunctionDroppedEvent
+
+       AggregateCreatedEvents []OnAggregateCreatedEvent
+       AggregateUpdatedEvents []OnAggregateUpdatedEvent
+       AggregateDroppedEvents []OnAggregateDroppedEvent
+
+       TypeCreatedEvents []OnUserTypeCreatedEvent
+       TypeUpdatedEvents []OnUserTypeUpdatedEvent
+       TypeDroppedEvents []OnUserTypeDroppedEvent
+}
+
+// OnAggregateCreated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnAggregateCreated(event 
OnAggregateCreatedEvent) {
+       (*s).AggregateCreatedEvents = append(s.AggregateCreatedEvents, event)
+}
+
+// OnAggregateDropped implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnAggregateDropped(event 
OnAggregateDroppedEvent) {
+       (*s).AggregateDroppedEvents = append(s.AggregateDroppedEvents, event)
+}
+
+// OnAggregateUpdated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnAggregateUpdated(event 
OnAggregateUpdatedEvent) {
+       (*s).AggregateUpdatedEvents = append(s.AggregateUpdatedEvents, event)
+}
+
+// OnFunctionCreated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnFunctionCreated(event 
OnFunctionCreatedEvent) {
+       (*s).FunctionCreatedEvents = append(s.FunctionCreatedEvents, event)
+}
+
+// OnFunctionDropped implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnFunctionDropped(event 
OnFunctionDroppedEvent) {
+       (*s).FunctionDroppedEvents = append(s.FunctionDroppedEvents, event)
+}
+
+// OnFunctionUpdated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnFunctionUpdated(event 
OnFunctionUpdatedEvent) {
+       (*s).FunctionUpdatedEvents = append(s.FunctionUpdatedEvents, event)
+}
+
+// OnKeyspaceCreated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnKeyspaceCreated(event 
OnKeyspaceCreatedEvent) {
+       (*s).KeyspaceCreatedEvents = append(s.KeyspaceCreatedEvents, event)
+}
+
+// OnKeyspaceDropped implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnKeyspaceDropped(event 
OnKeyspaceDroppedEvent) {
+       (*s).KeyspaceDroppedEvents = append(s.KeyspaceDroppedEvents, event)
+}
+
+// OnKeyspaceUpdated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnKeyspaceUpdated(event 
OnKeyspaceUpdatedEvent) {
+       (*s).KeyspaceUpdatedEvents = append(s.KeyspaceUpdatedEvents, event)
+}
+
+// OnTableCreated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnTableCreated(event OnTableCreatedEvent) {
+       (*s).TableCreatedEvents = append(s.TableCreatedEvents, event)
+}
+
+// OnTableDropped implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnTableDropped(event OnTableDroppedEvent) {
+       (*s).TableDroppedEvents = append(s.TableDroppedEvents, event)
+}
+
+// OnTableUpdated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnTableUpdated(event OnTableUpdatedEvent) {
+       (*s).TableUpdatedEvents = append(s.TableUpdatedEvents, event)
+}
+
+// OnTypeCreated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnUserTypeCreated(event 
OnUserTypeCreatedEvent) {
+       (*s).TypeCreatedEvents = append(s.TypeCreatedEvents, event)
+}
+
+// OnTypeDropped implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnUserTypeDropped(event 
OnUserTypeDroppedEvent) {
+       (*s).TypeDroppedEvents = append(s.TypeDroppedEvents, event)
+}
+
+// OnTypeUpdated implements [SchemaChangeListener].
+func (s *schemaChangesTestListener) OnUserTypeUpdated(event 
OnUserTypeUpdatedEvent) {
+       (*s).TypeUpdatedEvents = append(s.TypeUpdatedEvents, event)
+}
+
+func (s *schemaChangesTestListener) clear() {
+       s.KeyspaceCreatedEvents = nil
+       s.KeyspaceDroppedEvents = nil
+       s.KeyspaceUpdatedEvents = nil
+
+       s.TableCreatedEvents = nil
+       s.TableUpdatedEvents = nil
+       s.TableDroppedEvents = nil
+
+       s.FunctionCreatedEvents = nil
+       s.FunctionUpdatedEvents = nil
+       s.FunctionDroppedEvents = nil
+
+       s.AggregateCreatedEvents = nil
+       s.AggregateUpdatedEvents = nil
+       s.AggregateDroppedEvents = nil
+
+       s.TypeCreatedEvents = nil
+       s.TypeUpdatedEvents = nil
+       s.TypeDroppedEvents = nil
+}
+
+func TestSchemaEvents(t *testing.T) {

Review Comment:
   Added simple tests for this - basically just checking if listeners were 
called during session initialization



-- 
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