From 19f6ac9de7eaf659d9aa75937b26398b26b59d74 Mon Sep 17 00:00:00 2001 From: Manuel Kreutz Date: Sun, 9 Apr 2017 16:54:39 -0400 Subject: [PATCH] extend test coverage of helper function --- common/common_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/common/common_test.go b/common/common_test.go index 80d58f22..4aaf6c61 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -272,11 +272,17 @@ func TestUnixTimestampStrToTime(t *testing.T) { } func TestGetURIPath(t *testing.T) { - testURI := "https://api.gdax.com/accounts" - expectedOutput := "/accounts" - actualOutput := GetURIPath(testURI) - if actualOutput != expectedOutput { - t.Error(fmt.Sprintf("Test failed. Expected '%s'. Actual '%s'.", - expectedOutput, actualOutput)) + // mapping of input vs expected result + testTable := map[string]string{ + "https://api.gdax.com/accounts": "/accounts", + "https://api.gdax.com/accounts?a=1&b=2": "/accounts?a=1&b=2", + "ht:tp:/invalidurl": "", + } + for testInput, expectedOutput := range testTable { + actualOutput := GetURIPath(testInput) + if actualOutput != expectedOutput { + t.Error(fmt.Sprintf("Test failed. Expected '%s'. Actual '%s'.", + expectedOutput, actualOutput)) + } } }