package models_test import ( "github.com/cloudfoundry-incubator/cf-tcp-router/models" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("RoutingTable", func() { var routingTable models.RoutingTable BeforeEach(func() { routingTable = models.NewRoutingTable() }) Describe("Set", func() { Context("when a new entry is added", func() { It("adds the entry", func() { routingKey := models.RoutingKey{12} routingTableEntry := models.RoutingTableEntry{ Backends: map[models.BackendServerInfo]struct{}{ models.BackendServerInfo{"some-ip", 1234}: struct{}{}, }, } ok := routingTable.Set(routingKey, routingTableEntry) Expect(ok).To(BeTrue()) Expect(routingTable.Get(routingKey)).To(Equal(routingTableEntry)) Expect(routingTable.Size()).To(Equal(1)) }) })
var _ = Describe("Updater", func() { const ( externalPort1 = uint16(2222) externalPort2 = uint16(2223) externalPort4 = uint16(2224) externalPort5 = uint16(2225) externalPort6 = uint16(2226) routerGroupGuid = "rtrgrp001" ) var ( routingTable *models.RoutingTable existingRoutingKey1 models.RoutingKey existingRoutingTableEntry1 models.RoutingTableEntry existingRoutingKey2 models.RoutingKey existingRoutingTableEntry2 models.RoutingTableEntry updater routing_table.Updater fakeConfigurer *fakes.FakeRouterConfigurer fakeRoutingApiClient *fake_routing_api.FakeClient fakeTokenFetcher *testTokenFetcher.FakeTokenFetcher tcpEvent routing_api.TcpEvent ) verifyRoutingTableEntry := func(key models.RoutingKey, entry models.RoutingTableEntry) { existingEntry := routingTable.Get(key) Expect(existingEntry).NotTo(BeZero()) Expect(existingEntry).Should(Equal(entry)) } BeforeEach(func() { fakeConfigurer = new(fakes.FakeRouterConfigurer) fakeRoutingApiClient = new(fake_routing_api.FakeClient)