Expect(env["AAAAA"]).To(Equal("1")) Expect(env["CCC"]).To(Equal("4")) }) It("only uses exact key matches when grabbing from the environment", func() { env := factory.BuildEnvironment([]string{"AAA"}) Expect(env["AAA"]).To(Equal("2")) Expect(env["AAAAA"]).To(BeEmpty()) }) }) Describe("ParseTcpRoutes", func() { Context("when valid tcp routes is passed", func() { It("returns a valid TcpRoutes", func() { tcpRoutes, err := factory.ParseTcpRoutes("6379:50000,5222:50001") Expect(err).ShouldNot(HaveOccurred()) Expect(tcpRoutes).Should(ContainExactly( app_runner.TcpRoutes{ app_runner.TcpRoute{ ExternalPort: 50000, Port: 6379, }, app_runner.TcpRoute{ ExternalPort: 50001, Port: 5222, }, }, )) }) })
It("only uses exact key matches when grabbing from the environment", func() { envVars := factory.BuildEnvironment([]string{"AAA"}) aaaVar, found := envVars["AAA"] Expect(found).To(BeTrue()) Expect(aaaVar).To(Equal("2")) aaaaaVar, found := envVars["AAAAA"] Expect(found).To(BeFalse()) Expect(aaaaaVar).To(BeEmpty()) }) }) Describe("ParseTcpRoutes", func() { It("parses delimited tcp routes into the TcpRoutes struct", func() { tcpRoutes, err := factory.ParseTcpRoutes("50000:6379,50001:5222") Expect(err).NotTo(HaveOccurred()) Expect(tcpRoutes).To(ContainExactly(app_runner.TcpRoutes{ {ExternalPort: 50000, Port: 6379}, {ExternalPort: 50001, Port: 5222}, })) }) Context("when a malformed tcp routes is passed", func() { It("errors out when the container port is not an int", func() { _, err := factory.ParseTcpRoutes("50000:woo") Expect(err).To(MatchError(command_factory.InvalidPortErrorMessage)) }) It("errors out when the tcp route is incomplete", func() { _, err := factory.ParseTcpRoutes("5222,50000")