summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/agent/module/registry_test.go
blob: c9f31105a5ae4ec9645b747868bb1558bbdfe06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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{})
		})

}