Esempio n. 1
0
	})

	Describe("Update", func() {
		Context("when the template id is meant to be updated", func() {
			It("updates the record in the database", func() {
				client := models.Client{
					ID:         "my-client",
					TemplateID: "my-template",
				}

				client, err := repo.Upsert(conn, client)
				if err != nil {
					panic(err)
				}

				client.ID = "my-client"
				client.Description = "My Client"
				client.TemplateID = "new-template"

				client, err = repo.Update(conn, client)
				Expect(err).NotTo(HaveOccurred())

				client, err = repo.Find(conn, "my-client")
				if err != nil {
					panic(err)
				}

				Expect(client.ID).To(Equal("my-client"))
				Expect(client.Description).To(Equal("My Client"))
				Expect(client.CreatedAt).To(BeTemporally("~", time.Now(), 2*time.Second))
				Expect(client.TemplateID).To(Equal("new-template"))