From e1d63fc0bc769feb27b2ccfb6c758d342dfcbb83 Mon Sep 17 00:00:00 2001 From: zak-sw <60413679+zak-sw@users.noreply.github.com> Date: Sun, 2 May 2021 15:55:07 -0600 Subject: [PATCH] Add files via upload --- features/payments_test.go | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 features/payments_test.go diff --git a/features/payments_test.go b/features/payments_test.go new file mode 100644 index 0000000..4d2bdaa --- /dev/null +++ b/features/payments_test.go @@ -0,0 +1,46 @@ +package payments + +import "testing" + +func TestProcessPAIN(t *testing.T) { + data := []string{"", ""} + _, err := ProcessPAIN(data) + if err == nil { + t.Errorf("ProcessPAIN does not pass. Looking for %v, got %v", "Not all data is present. Run pain~help to check for needed PAIN data", nil) + } + + data = []string{"", "", "not integer"} + _, err = ProcessPAIN(data) + if err == nil { + t.Errorf("ProcessPAIN CheckTransactionType does not pass. Looking for %v, got %v", "Could not get type of PAIN transaction", nil) + } + + data = []string{"", "", "1"} + _, err = ProcessPAIN(data) + if err == nil { + t.Errorf("ProcessPAIN PainType1 does not pass. Looking for %v, got %v", "Not all data is present. Run pain~help to check for needed PAIN data", nil) + } + + data = []string{"", "", "1000"} + _, err = ProcessPAIN(data) + if err == nil { + t.Errorf("ProcessPAIN PainType1000 does not pass. Looking for %v, got %v", "Not all data is present. Run pain~help to check for needed PAIN data", nil) + } +} + +func BenchmarkProcessPAIN(b *testing.B) { + for n := 0; n < b.N; n++ { + // None of these pass/do inserts into transaction table + data := []string{"", ""} + _, _ = ProcessPAIN(data) + + data = []string{"", "", "not integer"} + _, _ = ProcessPAIN(data) + + data = []string{"", "", "1"} + _, _ = ProcessPAIN(data) + + data = []string{"", "", "1000"} + _, _ = ProcessPAIN(data) + } +} \ No newline at end of file