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

		Context("when setting pre-existing routing key", func() {
			var (
				routingKey                models.RoutingKey
				existingRoutingTableEntry models.RoutingTableEntry
			)
			BeforeEach(func() {
				routingKey = models.RoutingKey{12}
				existingRoutingTableEntry = models.RoutingTableEntry{
					Backends: map[models.BackendServerInfo]struct{}{
						models.BackendServerInfo{"some-ip-1", 1234}: struct{}{},
						models.BackendServerInfo{"some-ip-2", 1234}: struct{}{},
					},
				},
			}
		})

		Context("when routing api returns tcp route mappings", func() {
			BeforeEach(func() {
				fakeRoutingApiClient.TcpRouteMappingsReturns(tcpMappings, nil)
			})

			It("updates the routing table with that data", func() {
				go invokeSync(doneChannel)
				Eventually(doneChannel).Should(BeClosed())

				Expect(fakeTokenFetcher.FetchTokenCallCount()).To(Equal(1))
				Expect(fakeRoutingApiClient.TcpRouteMappingsCallCount()).To(Equal(1))
				Expect(routingTable.Size()).To(Equal(2))
				expectedRoutingTableEntry1 := models.NewRoutingTableEntry(
					models.BackendServerInfos{
						models.BackendServerInfo{"some-ip-1", 61000},
						models.BackendServerInfo{"some-ip-2", 61001},
					},
				)
				verifyRoutingTableEntry(models.RoutingKey{externalPort1}, expectedRoutingTableEntry1)
				expectedRoutingTableEntry2 := models.NewRoutingTableEntry(
					models.BackendServerInfos{
						models.BackendServerInfo{"some-ip-3", 60000},
						models.BackendServerInfo{"some-ip-4", 60000},
					},
				)
				verifyRoutingTableEntry(models.RoutingKey{externalPort2}, expectedRoutingTableEntry2)
			})