testing: Use Time.Equal for date comparisons

Postgres actually preserves the timezone, unlike sqlite and mysql...
This commit is contained in:
Aaron Lindsay 2017-11-17 05:19:27 -05:00
parent 00e1e899c0
commit 50dd7b1d26
2 changed files with 6 additions and 6 deletions

View File

@ -64,7 +64,7 @@ func TestCreatePrice(t *testing.T) {
if p.CurrencyId != d.securities[orig.CurrencyId].SecurityId {
t.Errorf("CurrencyId doesn't match")
}
if p.Date != orig.Date {
if !p.Date.Equal(orig.Date) {
t.Errorf("Date doesn't match")
}
if p.Value != orig.Value {
@ -94,7 +94,7 @@ func TestGetPrice(t *testing.T) {
if p.CurrencyId != d.securities[orig.CurrencyId].SecurityId {
t.Errorf("CurrencyId doesn't match")
}
if p.Date != orig.Date {
if !p.Date.Equal(orig.Date) {
t.Errorf("Date doesn't match")
}
if p.Value != orig.Value {
@ -131,7 +131,7 @@ func TestGetPrices(t *testing.T) {
found := false
for _, p := range *pl.Prices {
if p.SecurityId == d.securities[orig.SecurityId].SecurityId && p.CurrencyId == d.securities[orig.CurrencyId].SecurityId && p.Date == orig.Date && p.Value == orig.Value && p.RemoteId == orig.RemoteId {
if p.SecurityId == d.securities[orig.SecurityId].SecurityId && p.CurrencyId == d.securities[orig.CurrencyId].SecurityId && p.Date.Equal(orig.Date) && p.Value == orig.Value && p.RemoteId == orig.RemoteId {
if _, ok := foundIds[p.PriceId]; ok {
continue
}
@ -177,7 +177,7 @@ func TestUpdatePrice(t *testing.T) {
if p.CurrencyId != curr.CurrencyId {
t.Errorf("CurrencyId doesn't match")
}
if p.Date != curr.Date {
if !p.Date.Equal(curr.Date) {
t.Errorf("Date doesn't match")
}
if p.Value != curr.Value {

View File

@ -87,8 +87,8 @@ func ensureTransactionsMatch(t *testing.T, expected, tran *handlers.Transaction,
if tran.Description != expected.Description {
t.Errorf("Description doesn't match")
}
if tran.Date != expected.Date {
t.Errorf("Date doesn't match")
if !tran.Date.Equal(expected.Date) {
t.Errorf("Date (%+v) differs from expected (%+v)", tran.Date, expected.Date)
}
if len(tran.Splits) != len(expected.Splits) {