1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-12-26 07:33:21 -05:00

testing: Test Lua Prices

This commit is contained in:
Aaron Lindsay 2017-11-10 20:49:45 -05:00
parent 9b1b682bac
commit 79ed5dad9f

View File

@ -0,0 +1,23 @@
package handlers_test
import (
"fmt"
"strconv"
"testing"
)
func TestLuaPrices(t *testing.T) {
RunWith(t, &data[0], func(t *testing.T, d *TestData) {
security := d.securities[1]
currency := d.securities[0]
simpleLuaTest(t, d.clients[0], []LuaTest{
{"Security:ClosestPrice", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2016-11-19'))", security.SecurityId, currency.SecurityId), fmt.Sprintf("225.24 %s (%s)", currency.Symbol, security.Symbol)},
{"Security:ClosestPrice(2)", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2017-01-04'))", security.SecurityId, currency.SecurityId), fmt.Sprintf("226.58 %s (%s)", currency.Symbol, security.Symbol)},
{"PriceId", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2016-11-19')).PriceId", security.SecurityId, currency.SecurityId), strconv.FormatInt(d.prices[0].PriceId, 10)},
{"Security", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2016-11-19')).Security == secs[%d]", security.SecurityId, currency.SecurityId, security.SecurityId), "true"},
{"Currency", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2016-11-19')).Currency == secs[%d]", security.SecurityId, currency.SecurityId, currency.SecurityId), "true"},
{"Value", fmt.Sprintf("secs = get_securities(); return secs[%d]:ClosestPrice(secs[%d], date.new('2098-11-09')).Value", security.SecurityId, currency.SecurityId), "227.21"},
})
})
}