) BeforeEach(func() { // create an account for testing accountIn := &models.Account{} account, err = createServ.Run(dbSession, *accountIn) if err != nil { fmt.Println(err) } // fmt.Println("Account saved", accountIn.Id) }) It("Saved the account", func() { Expect(account.Id).NotTo(BeEmpty()) }) It("Updates the account", func() { account.Name = "No name" _, err := service.Run(dbSession, account) Expect(err).To(BeNil()) }) It("fails if account doesnt have an id", func() { account.Id = "" _, err := service.Run(dbSession, account) Expect(err).NotTo(BeNil()) }) })
. "github.com/onsi/gomega" "github.com/sporto/kic/api/models" "github.com/sporto/kic/api/services/accounts" ) var _ = Describe("GetServ", func() { var ( service accounts.GetServ accountId string createAccountServ accounts.CreateServ ) BeforeEach(func() { accountIn := new(models.Account) accountIn.Name = "X" accountOut, err := createAccountServ.Run(dbSession, *accountIn) if err != nil { fmt.Println("Account not created") } accountId = accountOut.Id }) It("Saved the account", func() { Expect(accountId).NotTo(BeEmpty()) }) It("Gets the account", func() { account, err := service.Run(dbSession, accountId) Expect(err).To(BeNil()) Expect(account.Name).To(Equal("X"))