Exemplo n.º 1
0
	It("updates the account balance", func() {
		_, err := service.Run(dbSession, *transaction)
		Expect(err).To(BeNil())
		getAccountServ := new(accounts.GetServ)
		account, err = getAccountServ.Run(dbSession, account.Id)
		Expect(account.CurrentBalance).To(Equal(150.0))
	})

	It("has the current balance", func() {
		transaction, _ := service.Run(dbSession, *transaction)
		Expect(transaction.Balance).To(Equal(150.0))
	})

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