| 344 | } |
| 345 | |
| 346 | func TestIsStock(t *testing.T) { |
| 347 | orig := dirs |
| 348 | t.Cleanup(func() { dirs = orig }) |
| 349 | |
| 350 | t.Run("fallback heuristic when stock dir is not initialized", func(t *testing.T) { |
| 351 | dirs = directories{} |
| 352 | assert.True(t, IsStock("/usr/lib/netdata/conf.d/go.d/module.conf")) |
| 353 | assert.False(t, IsStock("/etc/netdata/go.d/module.conf")) |
| 354 | }) |
| 355 | |
| 356 | t.Run("uses configured stock root when available", func(t *testing.T) { |
| 357 | dirs = directories{stockConfigDir: "/custom/stock"} |
| 358 | assert.True(t, IsStock("/custom/stock/go.d/module.conf")) |
| 359 | assert.False(t, IsStock("/usr/lib/netdata/conf.d/go.d/module.conf")) |
| 360 | assert.False(t, IsStock("/etc/netdata/go.d/module.conf")) |
| 361 | }) |
| 362 | } |