1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-31 16:00:05 -04:00

testing: Test deleting transactions

This commit is contained in:
Aaron Lindsay 2017-10-23 20:49:27 -04:00
parent 9b00bc8db1
commit 45b6482b15

View File

@ -246,7 +246,32 @@ func TestUpdateTransaction(t *testing.T) {
} else {
t.Fatalf("Unexpected error updating zero splits")
}
}
})
}
func TestDeleteTransaction(t *testing.T) {
RunWith(t, &data[0], func(t *testing.T, d *TestData) {
for i := 1; i < len(data[0].transactions); i++ {
orig := data[0].transactions[i]
curr := d.transactions[i]
err := deleteTransaction(d.clients[orig.UserId], &curr)
if err != nil {
t.Fatalf("Error deleting transaction: %s\n", err)
}
_, err = getTransaction(d.clients[orig.UserId], curr.TransactionId)
if err == nil {
t.Fatalf("Expected error fetching deleted transaction")
}
if herr, ok := err.(*handlers.Error); ok {
if herr.ErrorId != 3 { // Invalid requeset
t.Fatalf("Unexpected API error fetching deleted transaction: %s", herr)
}
} else {
t.Fatalf("Unexpected error fetching deleted transaction")
}
}
})
}