[]string{"Incorrect Usage", "Requires an argument"}, )) Expect(passed).To(BeFalse()) }) }) Describe("when invoked by a plugin", func() { var ( pluginAppModel *plugin_models.GetAppModel ) BeforeEach(func() { app = makeAppWithRoute("my-app") appInstance := models.AppInstanceFields{ State: models.InstanceRunning, Since: testtime.MustParse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2012"), Details: "normal", CpuUsage: 1.0, DiskQuota: 1 * formatters.GIGABYTE, DiskUsage: 32 * formatters.MEGABYTE, MemQuota: 64 * formatters.MEGABYTE, MemUsage: 13 * formatters.MEGABYTE, } appInstance2 := models.AppInstanceFields{ State: models.InstanceDown, Details: "failure", Since: testtime.MustParse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Apr 1 15:04:05 -0700 MST 2012"), } instances := []models.AppInstanceFields{appInstance, appInstance2}
server, handler = testnet.NewServer(requests) config.SetApiEndpoint(server.URL) } Describe("list recent events", func() { It("returns the most recent events", func() { setupTestServer(eventsRequest) list, err := repo.RecentEvents("my-app-guid", 2) Expect(err).ToNot(HaveOccurred()) Expect(list).To(ConsistOf([]models.EventFields{ models.EventFields{ Guid: "event-1-guid", Name: "audit.app.update", Timestamp: testtime.MustParse(eventTimestampFormat, "2014-01-21T00:20:11+00:00"), Description: "instances: 1, memory: 256, command: PRIVATE DATA HIDDEN, environment_json: PRIVATE DATA HIDDEN", ActorName: "*****@*****.**", }, models.EventFields{ Guid: "event-2-guid", Name: "audit.app.update", Timestamp: testtime.MustParse(eventTimestampFormat, "2014-01-21T00:20:11+00:00"), Description: "instances: 1, memory: 256, command: PRIVATE DATA HIDDEN, environment_json: PRIVATE DATA HIDDEN", ActorName: "*****@*****.**", }, })) }) }) })
It("Adds a packageUpdatedAt timestamp", func() { err := json.Unmarshal([]byte(` { "metadata": { "guid":"application-1-guid" }, "entity": { "package_updated_at": "2013-10-07T16:51:07+00:00" } }`), &resource) Expect(err).NotTo(HaveOccurred()) applicationModel := resource.ToModel() Expect(*applicationModel.PackageUpdatedAt).To(Equal(testtime.MustParse(eventTimestampFormat, "2013-10-07T16:51:07+00:00"))) }) }) Describe("NewApplicationEntityFromAppParams", func() { var ( appParams models.AppParams diskQuota, memory int64 healthCheckTimeout, instanceCount int diego, enableSSH bool packageUpdatedAt time.Time appPorts []int environmentVars map[string]interface{} buildpackURL,
"metadata": { "instance": "50dd66d3f8874b35988d23a25d19bfa0", "index": 3, "exit_status": -1, "exit_description": "unknown", "reason": "CRASHED" } } }`), &resource) Expect(err).NotTo(HaveOccurred()) eventFields := resource.ToFields() Expect(eventFields.Guid).To(Equal("event-1-guid")) Expect(eventFields.Name).To(Equal("app.crash")) Expect(eventFields.Timestamp).To(Equal(testtime.MustParse(eventTimestampFormat, "2013-10-07T16:51:07+00:00"))) Expect(eventFields.Description).To(Equal(`index: 3, reason: CRASHED, exit_description: unknown, exit_status: -1`)) }) It("unmarshals app update events", func() { err := json.Unmarshal([]byte(` { "metadata": { "guid": "event-1-guid" }, "entity": { "type": "audit.app.update", "timestamp": "2014-01-21T00:20:11+00:00", "metadata": { "request": { "state": "STOPPED",