diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/agent/module/registry_test.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/agent/module/registry_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/agent/module/registry_test.go b/src/go/collectors/go.d.plugin/agent/module/registry_test.go new file mode 100644 index 000000000..c9f31105a --- /dev/null +++ b/src/go/collectors/go.d.plugin/agent/module/registry_test.go @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package module + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestRegister(t *testing.T) { + modName := "modName" + registry := make(Registry) + + // OK case + assert.NotPanics( + t, + func() { + registry.Register(modName, Creator{}) + }) + + _, exist := registry[modName] + + require.True(t, exist) + + // Panic case + assert.Panics( + t, + func() { + registry.Register(modName, Creator{}) + }) + +} |