From 45b6482b15b9eaea5a5be217b8bc32d8b8ed1695 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Mon, 23 Oct 2017 20:49:27 -0400 Subject: [PATCH] testing: Test deleting transactions --- internal/handlers/transactions_test.go | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/internal/handlers/transactions_test.go b/internal/handlers/transactions_test.go index 3c00cca..d79f9f9 100644 --- a/internal/handlers/transactions_test.go +++ b/internal/handlers/transactions_test.go @@ -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") + } } }) }