Beispiel #1
0
		routes = []db.Route{
			{
				Route:           "http://127.0.0.1/a/valid/route",
				IP:              "127.0.0.1",
				Port:            8080,
				TTL:             maxTTL,
				LogGuid:         "log_guid",
				RouteServiceUrl: "https://my-rs.example.com",
			},
		}
	})

	Describe(".ValidateCreate", func() {
		It("does not return an error if all route inputs are valid", func() {
			err := validator.ValidateCreate(routes, maxTTL)
			Expect(err).To(BeNil())
		})

		Context("when any route has an invalid value", func() {
			BeforeEach(func() {
				routes = append(routes, routes[0])
			})

			It("returns an error if any ttl is greater than max ttl", func() {
				routes[1].TTL = maxTTL + 1

				err := validator.ValidateCreate(routes, maxTTL)
				Expect(err.Type).To(Equal(routing_api.RouteInvalidError))
				Expect(err.Error()).To(Equal(fmt.Sprintf("Max ttl is %d", maxTTL)))
			})