From 095f9a7f9c00e4c9d1442c3761e03c7ed5f5edfc Mon Sep 17 00:00:00 2001 From: favonia Date: Sun, 10 Sep 2023 07:09:15 -0500 Subject: [PATCH] test(provider): test MustNewCustom --- internal/provider/custom_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/provider/custom_test.go b/internal/provider/custom_test.go index 9c8de687..e5034d29 100644 --- a/internal/provider/custom_test.go +++ b/internal/provider/custom_test.go @@ -70,3 +70,29 @@ func TestNewCustom(t *testing.T) { }) } } + +func TestMustNewCustom(t *testing.T) { + t.Parallel() + + for _, tc := range []struct { + input string + ok bool + }{ + {"https://1.2.3.4", true}, + {":::::", false}, + {"http://1.2.3.4", true}, + {"ftp://1.2.3.4", false}, + {"", false}, + } { + tc := tc + t.Run(tc.input, func(t *testing.T) { + t.Parallel() + + if tc.ok { + require.NotPanics(t, func() { provider.MustNewCustom(tc.input) }) + } else { + require.Panics(t, func() { provider.MustNewCustom(tc.input) }) + } + }) + } +}