-
Notifications
You must be signed in to change notification settings - Fork 0
/
budget_test.go
111 lines (107 loc) · 2.28 KB
/
budget_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package budget_test
import (
"github.com/cassamajor/budget"
"testing"
)
func TestNewRat(t *testing.T) {
tests := []struct {
name string
input int
expected budget.Balance
}{
{"Convert an int into a Balance", 1000000, 1000},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := budget.NewRat(tc.input)
if got != tc.expected {
t.Errorf("Expected: %v, Got: %v", tc.expected, got)
}
})
}
}
//func TestNewBudget(t *testing.T) {
// t.Parallel()
//
// tests := []struct {
// name string
// args budget.Budget
// want budget.Summary
// }{
// {
// name: "No Token is set as an environment variable",
// args: budget.Budget{
// Month: "2024-06-01",
// },
// want: errors.New("API token is required"),
// },
// {
// name: "WithToken is passed with an empty string",
// args: budget.Budget{
// Month: "2024-06-01",
// APIToken: "",
// },
// want: errors.New("token cannot be empty"),
// },
// {
// name: "Token is set as an environment variable",
// args: budget.Budget{
// Month: "2024-06-01",
// APIToken: "",
// },
// want: budget.Summary{},
// },
// {
// name: "WithMonth is passed with an empty string",
// args: budget.Budget{
// Month: "",
// },
// want: errors.New("token cannot be empty"),
// },
// {
// name: "No Month Set",
// args: budget.Budget{
// APIToken: "gibberish",
// },
// want: budget.Summary{},
// },
// {
// name: "Month is set with invalid value",
// args: budget.Budget{
// APIToken: "gibberish",
// Month: "01-02-2006",
// },
// want: budget.Summary{},
// },
// {
// name: "Token and Month Set",
// args: budget.Budget{
// APIToken: "gibberish",
// Month: "2024-06-01",
// },
// want: budget.Summary{},
// },
// {
// name: "Token and Month Unset",
// args: budget.Budget{},
// want: budget.Summary{},
// },
// }
// for _, tt := range tests {
// t.Run(tt.name, func(t *testing.T) {
// //t.Parallel()
//
// token := budget.WithToken(tt.args.APIToken)
// m := budget.WithMonth(tt.args.Month)
// b, err := budget.NewBudget(token, m)
//
// if err != nil {
// t.Fatal(err)
// }
//
// if got := b.Budget(); !reflect.DeepEqual(got, tt.want) {
// t.Errorf("got =\n %v, want =\n %v", got, tt.want)
// }
// })
// }
//}