| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package jobruntime |
| 4 | |
| 5 | import ( |
| 6 | "bytes" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/netdata/netdata/go/plugins/logger" |
| 10 | "github.com/stretchr/testify/assert" |
| 11 | ) |
| 12 | |
| 13 | func TestJobLoggerAttrs(t *testing.T) { |
| 14 | var buf bytes.Buffer |
| 15 | |
| 16 | logger.NewWithWriter(&buf). |
| 17 | With(jobLoggerAttrs("module", "job", "stock/file reader")...). |
| 18 | Info("captured") |
| 19 | |
| 20 | out := buf.String() |
| 21 | assert.Contains(t, out, "collector=module") |
| 22 | assert.Contains(t, out, "job=job") |
| 23 | assert.Contains(t, out, "config_source=\"stock/file reader\"") |
| 24 | } |