master
go 32 lines 650 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package sd
4
5 import (
6 "testing"
7
8 "github.com/netdata/netdata/go/plugins/plugin/framework/confgroup"
9 "github.com/stretchr/testify/assert"
10 )
11
12 func TestSourceTypeFromPath(t *testing.T) {
13 tests := map[string]struct {
14 path string
15 want string
16 }{
17 "user path under /etc": {
18 path: "/etc/netdata/sd.d/test.conf",
19 want: confgroup.TypeUser,
20 },
21 "stock path outside /etc": {
22 path: "/usr/lib/netdata/conf.d/sd.d/test.conf",
23 want: confgroup.TypeStock,
24 },
25 }
26
27 for name, tc := range tests {
28 t.Run(name, func(t *testing.T) {
29 assert.Equal(t, tc.want, sourceTypeFromPath(tc.path))
30 })
31 }
32 }