fakeReceptorClientCreator.CreateReceptorClientReturns(fakeReceptorClient) targetVerifier = target_verifier.New(fakeReceptorClientCreator) }) It("returns up=true, auth=true if the receptor does not return an error", func() { up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com") Expect(err).NotTo(HaveOccurred()) Expect(up).To(BeTrue()) Expect(auth).To(BeTrue()) Expect(fakeReceptorClientCreator.CreateReceptorClientCallCount()).To(Equal(1)) Expect(fakeReceptorClientCreator.CreateReceptorClientArgsForCall(0)).To(Equal("http://receptor.mylattice.com")) }) It("returns up=true, auth=false if the receptor returns an authorization error", func() { fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{ Type: receptor.Unauthorized, Message: "Go home. You're not welcome here.", }) up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com") Expect(err).NotTo(HaveOccurred()) Expect(up).To(BeTrue()) Expect(auth).To(BeFalse()) }) It("returns up=true, auth=false, err=(the bubbled up error) if there is a receptor error other than unauthorized", func() { fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, receptor.Error{ Type: receptor.UnknownError, Message: "It all happened so fast... I just dunno what went wrong.", }) up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
Port: uint16(4444), }, }, } err := appRunner.CreateApp(createAppParams) Expect(err).NotTo(HaveOccurred()) Expect(fakeReceptorClient.CreateDesiredLRPCallCount()).To(Equal(1)) Expect(fakeReceptorClient.CreateDesiredLRPArgsForCall(0).Monitor).To(BeNil()) }) }) Context("when monitoring a port", func() { It("sets the timeout for the monitor", func() { fakeReceptorClient.DesiredLRPsReturns([]receptor.DesiredLRPResponse{}, nil) createAppParams = app_runner.CreateAppParams{ AppEnvironmentParams: app_runner.AppEnvironmentParams{ User: "******", Monitor: app_runner.MonitorConfig{ Method: app_runner.PortMonitor, Port: 2345, Timeout: 15 * time.Second, }, ExposedPorts: []uint16{2345}, }, } err := appRunner.CreateApp(createAppParams) Expect(err).NotTo(HaveOccurred())
DiskMB: 256, MemoryMB: 100, Routes: route_helpers.Routes{ AppRoutes: route_helpers.AppRoutes{ {Hostnames: []string{"happy", "joy"}}, }}.RoutingInfo(), EnvironmentVariables: []receptor.EnvironmentVariable{}, StartTimeout: 30, CPUWeight: 94, Ports: []uint16{2378, 67}, LogGuid: "asdf-ojf93-9sdcsdk", LogSource: "proc1-log", Annotation: "Best process this side o' the Mississippi.", }, } fakeReceptorClient.DesiredLRPsReturns(desiredLrps, nil) actualLrps := []receptor.ActualLRPResponse{ {ProcessGuid: "process3-stopping", InstanceGuid: "guid4", Index: 1, State: receptor.ActualLRPStateRunning}, {ProcessGuid: "process1-scalingUp", InstanceGuid: "guid1", Index: 1, State: receptor.ActualLRPStateRunning}, {ProcessGuid: "process1-scalingUp", InstanceGuid: "guid2", Index: 2, State: receptor.ActualLRPStateClaimed}, {ProcessGuid: "process2-scalingDown", InstanceGuid: "guid3", Index: 1, State: receptor.ActualLRPStateRunning}, } fakeReceptorClient.ActualLRPsReturns(actualLrps, nil) }) It("returns a list of alphabetically sorted examined apps", func() { appList, err := appExaminer.ListApps() Expect(err).NotTo(HaveOccurred()) Expect(appList).To(HaveLen(3))