Exemplo n.º 1
0
	})

	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())
	})

	It("fails if the account interests has not been updated", func() {
		account.LastInterestPaid = time.Now().AddDate(0, 0, -2) // two days
		_, err := updateAccountServ.Run(dbSession, account)
		Expect(err).To(BeNil())