| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package main |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/netdata/netdata/go/plugins/plugin/framework/collectorapi" |
| 9 | "github.com/stretchr/testify/assert" |
| 10 | ) |
| 11 | |
| 12 | func TestModuleRegistryWithSystemdPolicy(t *testing.T) { |
| 13 | base := collectorapi.Registry{ |
| 14 | "logind": collectorapi.Creator{}, |
| 15 | "other": collectorapi.Creator{}, |
| 16 | } |
| 17 | |
| 18 | withPolicy := moduleRegistryWithSystemdPolicy(base, 239) |
| 19 | assert.True(t, withPolicy["logind"].Disabled) |
| 20 | assert.False(t, withPolicy["other"].Disabled) |
| 21 | assert.False(t, base["logind"].Disabled, "base registry must remain unchanged") |
| 22 | |
| 23 | withoutPolicy := moduleRegistryWithSystemdPolicy(base, 250) |
| 24 | assert.False(t, withoutPolicy["logind"].Disabled) |
| 25 | assert.False(t, withoutPolicy["other"].Disabled) |
| 26 | } |