allow zero rows for apid_cluster in snapshot
diff --git a/listener.go b/listener.go index 41b7a8e..47c58a7 100644 --- a/listener.go +++ b/listener.go
@@ -52,13 +52,15 @@ switch table.Name { case LISTENER_TABLE_APID_CLUSTER: - if len(table.Rows) != 1 { + if len(table.Rows) > 1 { log.Panic("Illegal state for apid_cluster. Must be a single row.") } - ac := makeApidClusterFromRow(table.Rows[0]) - err := insertApidCluster(ac, tx) - if err != nil { - log.Panic("Snapshot update failed: %v", err) + for _, row := range table.Rows { + ac := makeApidClusterFromRow(row) + err := insertApidCluster(ac, tx) + if err != nil { + log.Panic("Snapshot update failed: %v", err) + } } case LISTENER_TABLE_DATA_SCOPE:
diff --git a/listener_test.go b/listener_test.go index 02d255d..893e81a 100644 --- a/listener_test.go +++ b/listener_test.go
@@ -30,21 +30,6 @@ Expect(getDB() == expectedDB).Should(BeTrue()) }) - It("should fail if zero apid_cluster rows", func() { - - event := common.Snapshot{ - SnapshotInfo: "test_snapshot_fail", - Tables: []common.Table{ - { - Name: LISTENER_TABLE_APID_CLUSTER, - Rows: []common.Row{}, - }, - }, - } - - Expect(func() { handler.Handle(&event) }).To(Panic()) - }) - It("should fail if more than one apid_cluster rows", func() { event := common.Snapshot{