-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
68 lines (50 loc) · 1.83 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"testing"
"time"
"github.com/jadson-medeiros/banks-adapter/adapters"
"github.com/jadson-medeiros/banks-adapter/domain"
)
func CreateBank1Mock() *adapters.Bank1Adapter {
return &adapters.Bank1Adapter{}
}
func CreateBank2Mock() *adapters.Bank2Adapter {
return &adapters.Bank2Adapter{}
}
func GetTransactionsBank1Mock() []domain.Transaction {
checkDeposit := domain.Transaction{Amount: 100, Type: domain.CREDIT, Text: "Check deposit"}
debidCardPurchase := domain.Transaction{Amount: 25.5, Type: domain.DEBIT, Text: "Debit card purchase"}
rentPayment := domain.Transaction{Amount: 225, Type: domain.DEBIT, Text: "Rent payment"}
return []domain.Transaction{checkDeposit, debidCardPurchase, rentPayment}
}
func GetTransactionsBank2Mock() []domain.Transaction {
purchase := domain.Transaction{Amount: 125, Type: domain.DEBIT, Text: "Amazon.com"}
carInsurance := domain.Transaction{Amount: 500, Type: domain.DEBIT, Text: "Car insurance"}
salary := domain.Transaction{Amount: 800, Type: domain.CREDIT, Text: "Salary"}
return []domain.Transaction{purchase, carInsurance, salary}
}
func TestGetTransactionsBank1(t *testing.T) {
bank := CreateBank1Mock()
result := bank.GetTransactions(100, time.Now(), time.Now())
expected := GetTransactionsBank1Mock()
if result == nil {
t.Errorf("result is nill")
return
}
if fmt.Sprint(result) != fmt.Sprint(expected) {
t.Errorf("result '%s', expected '%s'", fmt.Sprint(result), fmt.Sprint(expected))
}
}
func TestGetTransactionsBank2(t *testing.T) {
bank := CreateBank2Mock()
result := bank.GetTransactions(100, time.Now(), time.Now())
expected := GetTransactionsBank2Mock()
if result == nil {
t.Errorf("result is nill")
return
}
if fmt.Sprint(result) != fmt.Sprint(expected) {
t.Errorf("result '%s', expected '%s'", fmt.Sprint(result), fmt.Sprint(expected))
}
}