-
Notifications
You must be signed in to change notification settings - Fork 1
/
budget_test.go
48 lines (42 loc) · 1023 Bytes
/
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
package toshl_test
import (
"encoding/json"
"testing"
toshl "github.com/andreagrandi/toshl-go"
"github.com/stretchr/testify/assert"
)
func TestBudgetDecode(t *testing.T) {
var budget toshl.Budget
budgetJSON := []byte(`{
"id": "42",
"name": "Monthly budget",
"limit": 1000,
"amount": 78.4,
"planned": 12.6,
"median": 22,
"currency": {
"code": "USD",
"rate": 1,
"fixed": false
},
"from": "2013-02-01",
"to": "2013-02-30",
"rollover": false,
"modified": "2013-06-27T14:14:03+00:00Z",
"recurrence": {
"frequency": "monthly",
"interval": 1,
"start": "2012-06-01",
"iteration": 4
},
"status": "active",
"type": "regular",
"order": 0,
"categories": ["42"]
}`)
err := json.Unmarshal(budgetJSON, &budget)
if err != nil {
t.Errorf("Cannot decode Budget JSON")
}
assert.Nil(t, err)
}