-
Notifications
You must be signed in to change notification settings - Fork 1
/
oandafeeder_test.go
48 lines (39 loc) · 1.02 KB
/
oandafeeder_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 main
import (
"encoding/json"
"testing"
"github.com/alpacahq/marketstore/plugins/bgworker"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
var _ = Suite(&TestSuite{})
type TestSuite struct{}
func getConfig(data string) (ret map[string]interface{}) {
json.Unmarshal([]byte(data), &ret)
return
}
func (t *TestSuite) TestNew(c *C) {
var config = getConfig(`{
"symbols": ["EUR_USD"]
}`)
var worker *OandaFetcher
var ret bgworker.BgWorker
var err error
ret, err = NewBgWorker(config)
worker = ret.(*OandaFetcher)
c.Assert(len(worker.symbols), Equals, 1)
c.Assert(worker.symbols[0], Equals, "EUR_USD")
c.Assert(err, IsNil)
config = getConfig(``)
ret, err = NewBgWorker(config)
worker = ret.(*OandaFetcher)
c.Assert(err, IsNil)
c.Assert(len(worker.symbols), Equals, 4)
config = getConfig(`{
"query_start": "2017-01-02 00:00"
}`)
ret, err = NewBgWorker(config)
worker = ret.(*OandaFetcher)
c.Assert(err, IsNil)
c.Assert(worker.queryStart.IsZero(), Equals, false)
}