Пример #1
0
func fargoInstance(app env.App) *fargo.Instance {
	return &fargo.Instance{
		HostName:         app.URI(),
		PortJ:            fargo.Port{strconv.Itoa(appStdPort), "true"},
		SecurePortJ:      fargo.Port{strconv.Itoa(appStdSecurePort), "true"},
		App:              strings.ToUpper(app.Name),
		IPAddr:           app.Instance.Addr,
		VipAddress:       app.URI(),
		Status:           fargo.UP,
		Overriddenstatus: fargo.UNKNOWN,
		DataCenterInfo:   fargo.DataCenterInfo{Name: fargo.MyOwn},
		Metadata:         fargo.InstanceMetadata{Raw: []byte(fmt.Sprintf(`{"instanceId": "%s"}`, app.Instance.ID))},
		UniqueID: func(i fargo.Instance) string {
			return fmt.Sprintf("%s:%s", app.URI(), app.Instance.ID)
		},
	}
}
Пример #2
0
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("Error parsing VCAP_APPLICATION"))
		})
	})
})

var _ = Describe("App", func() {
	Describe(".URI", func() {
		var app env.App

		BeforeEach(func() {
			app.URIs = []string{"uri1", "uri2", "uri3"}
		})

		It("returns the first URI from the list of URIs", func() {
			Expect(app.URI()).To(Equal("uri1"))
		})

		Context("when the app does have an empty list of URIs", func() {
			BeforeEach(func() {
				app.URIs = []string{}
			})

			It("returns an empty string", func() {
				Expect(app.URI()).To(Equal(""))
			})
		})
	})
})

var vcapApplication = `
Пример #3
0
			app = env.App{
				ID:   "app-id",
				Name: "app-name",
				URIs: []string{"app-uri-1", "app-uri-2"},
				Host: "app-host",
				Port: 12345,
				Addr: "app-addr",
				Instance: env.AppInstance{
					ID:    "app-instance_id",
					Index: 99,
				},
			}

			assertInstance = func(i *fargo.Instance) {
				Expect(i.HostName).To(Equal(app.URI()))
				Expect(i.PortJ.Number).To(Equal("80"))
				Expect(i.PortJ.Enabled).To(Equal("true"))
				Expect(i.SecurePortJ.Number).To(Equal("443"))
				Expect(i.SecurePortJ.Enabled).To(Equal("true"))
				Expect(i.App).To(Equal(strings.ToUpper(app.Name)))
				Expect(i.IPAddr).To(Equal(app.Instance.Addr))
				Expect(i.VipAddress).To(Equal(app.URI()))
				Expect(i.Status).To(Equal(fargo.UP))
				Expect(i.Overriddenstatus).To(Equal(fargo.UNKNOWN))
				Expect(i.DataCenterInfo.Name).To(Equal(fargo.MyOwn))
				Expect(i.UniqueID).ToNot(BeNil())
				Expect(i.UniqueID(*i)).To(Equal(fmt.Sprintf("%s:%s", app.URI(), app.Instance.ID)))
			}
		)