mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
add account service test
This commit is contained in:
parent
2c70509ee8
commit
5a00e2fe20
|
@ -38,7 +38,7 @@ func (s *AccountService) InsertAsset(time time.Time, session string, name types.
|
||||||
borrowed,
|
borrowed,
|
||||||
net_asset,
|
net_asset,
|
||||||
price_in_usd)
|
price_in_usd)
|
||||||
values (?,?,?,?,?,?,?,?,?,?,?);
|
values (?,?,?,?,?,?,?,?,?,?,?,?,?);
|
||||||
`, session, name, account, time, v.Currency, v.InUSD, v.InBTC, v.Total, v.Available, v.Locked, v.Borrowed, v.NetAsset, v.PriceInUSD)
|
`, session, name, account, time, v.Currency, v.InUSD, v.InBTC, v.Total, v.Available, v.Locked, v.Borrowed, v.NetAsset, v.PriceInUSD)
|
||||||
|
|
||||||
err = multierr.Append(err, _err) // successful request
|
err = multierr.Append(err, _err) // successful request
|
||||||
|
|
41
pkg/service/account_test.go
Normal file
41
pkg/service/account_test.go
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccountService(t *testing.T) {
|
||||||
|
db, err := prepareDB(t)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
xdb := sqlx.NewDb(db.DB, "sqlite3")
|
||||||
|
service := &AccountService{DB: xdb}
|
||||||
|
|
||||||
|
t1 := time.Now()
|
||||||
|
err = service.InsertAsset(t1, "binance", types.ExchangeBinance, "main", types.AssetMap{
|
||||||
|
"BTC": types.Asset{
|
||||||
|
Currency: "BTC",
|
||||||
|
Total: fixedpoint.MustNewFromString("1.0"),
|
||||||
|
InUSD: fixedpoint.MustNewFromString("10.0"),
|
||||||
|
InBTC: fixedpoint.MustNewFromString("0.0001"),
|
||||||
|
Time: t1,
|
||||||
|
Locked: fixedpoint.MustNewFromString("0"),
|
||||||
|
Available: fixedpoint.MustNewFromString("1.0"),
|
||||||
|
Borrowed: fixedpoint.MustNewFromString("0"),
|
||||||
|
NetAsset: fixedpoint.MustNewFromString("1"),
|
||||||
|
PriceInUSD: fixedpoint.MustNewFromString("44870"),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user