var ( routingKey models.RoutingKey backendServerInfo models.BackendServerInfo ) BeforeEach(func() { routingKey = models.RoutingKey{12} backendServerInfo = models.BackendServerInfo{"some-ip", 1234} }) Context("when the routing key does not exist", func() { It("inserts the routing key with its backends", func() { routingTableEntry := models.RoutingTableEntry{ Backends: map[models.BackendServerInfo]struct{}{ backendServerInfo: struct{}{}, }, } ok := routingTable.UpsertBackendServerInfo(routingKey, backendServerInfo) Expect(ok).To(BeTrue()) Expect(routingTable.Get(routingKey)).Should(Equal(routingTableEntry)) Expect(routingTable.Size()).To(Equal(1)) }) }) Context("when the routing key does exist", func() { BeforeEach(func() { existingRoutingTableEntry := models.RoutingTableEntry{ Backends: map[models.BackendServerInfo]struct{}{ backendServerInfo: struct{}{}, }, } ok := routingTable.Set(routingKey, existingRoutingTableEntry) Expect(ok).To(BeTrue()) })