github.com/netdata/go.d.plugin@v0.58.1/agent/module/registry_test.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package module 4 5 import ( 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestRegister(t *testing.T) { 13 modName := "modName" 14 registry := make(Registry) 15 16 // OK case 17 assert.NotPanics( 18 t, 19 func() { 20 registry.Register(modName, Creator{}) 21 }) 22 23 _, exist := registry[modName] 24 25 require.True(t, exist) 26 27 // Panic case 28 assert.Panics( 29 t, 30 func() { 31 registry.Register(modName, Creator{}) 32 }) 33 34 }