From 2e2abc1c8c0412a98d4ac50903909dc0dcc2f43f Mon Sep 17 00:00:00 2001 From: Max Chadwick Date: Tue, 3 Nov 2020 20:34:41 -0500 Subject: [PATCH] Add logging for malformed arguments --- src/provider.go | 2 +- src/provider_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/provider.go b/src/provider.go index e938c3e..a944128 100644 --- a/src/provider.go +++ b/src/provider.go @@ -128,7 +128,7 @@ func (p Provider) raw (s string) string { argsStart := strings.Index(parts[2], "(") argsEnd := strings.Index(parts[2], ")") if argsStart == -1 || argsEnd == -1 || argsEnd < argsStart { - // TODO: Cover this with logging + logger.Error("Could not identify arguments for " + parts[2]) return "" } diff --git a/src/provider_test.go b/src/provider_test.go index 9521aaa..2819226 100644 --- a/src/provider_test.go +++ b/src/provider_test.go @@ -46,8 +46,8 @@ func TestGet(t *testing.T) { t.Errorf("Unsupported method not handled correctly") } - r7 := provider.Get("faker.Internet().Slug") - if r7 != "" { - t.Errorf("Got a value and was expecting empty string") + _ = provider.Get("faker.Internet().Slug") + if hook.LastEntry().Message != "Could not identify arguments for Slug" { + t.Errorf("Malformed arguments not handled correctly") } } \ No newline at end of file