extend test coverage of helper function

This commit is contained in:
Manuel Kreutz
2017-04-09 16:54:39 -04:00
parent 6e440a1a0c
commit 19f6ac9de7

View File

@@ -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))
}
}
}