forked from rwestlund/quickbooks-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_test.go
40 lines (35 loc) · 1.21 KB
/
account_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
package quickbooks
import (
"encoding/json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"testing"
)
func TestAccount(t *testing.T) {
jsonFile, err := os.Open("data/testing/account.json")
require.NoError(t, err)
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
require.NoError(t, err)
var r struct {
Account Account
Time Date
}
err = json.Unmarshal(byteValue, &r)
require.NoError(t, err)
assert.Equal(t, "MyJobs", r.Account.FullyQualifiedName)
assert.Equal(t, "MyJobs", r.Account.Name)
assert.Equal(t, "Asset", r.Account.Classification)
assert.Equal(t, "AccountsReceivable", r.Account.AccountSubType)
assert.Equal(t, json.Number("0"), r.Account.CurrentBalanceWithSubAccounts)
assert.Equal(t, "2014-12-31T09:29:05-08:00", r.Account.MetaData.CreateTime.String())
assert.Equal(t, "2014-12-31T09:29:05-08:00", r.Account.MetaData.LastUpdatedTime.String())
assert.Equal(t, AccountsReceivableAccountType, r.Account.AccountType)
assert.Equal(t, json.Number("0"), r.Account.CurrentBalance)
assert.True(t, r.Account.Active)
assert.Equal(t, "0", r.Account.SyncToken)
assert.Equal(t, "94", r.Account.ID)
assert.False(t, r.Account.SubAccount)
}