}) It("fails when no account id provided", func() { transaction.AccountId = "" _, err := service.Run(dbSession, *transaction) Expect(err).NotTo(BeNil()) }) It("fails if the account doesn't exist", func() { transaction.AccountId = "XYZ" _, err := service.Run(dbSession, *transaction) Expect(err).NotTo(BeNil()) }) It("fails if the transaction is already saved", func() { transaction.Id = "aaaa" _, err := service.Run(dbSession, *transaction) Expect(err).NotTo(BeNil()) }) It("fails if no credit or debit provided", func() { transaction.Credit = 0 transaction.Debit = 0 _, err := service.Run(dbSession, *transaction) Expect(err).NotTo(BeNil()) }) It("fails if the account doesn't have enough balance", func() { transaction.Debit = 150 _, err := service.Run(dbSession, *transaction) Expect(err).NotTo(BeNil())