@@ -298,6 +298,32 @@ func TestResolveCollector(t *testing.T) {
298298 })
299299}
300300
301+ func TestResolveCollectorLog (t * testing.T ) {
302+ t .Run ("Test 1: OTel Log Level Set In Config" , func (t * testing.T ) {
303+ viperInstance = viper .NewWithOptions (viper .KeyDelimiter (KeyDelimiter ))
304+
305+ viperInstance .Set (CollectorLogLevelKey , "info" )
306+ viperInstance .Set (CollectorLogPathKey , "/tmp/collector.log" )
307+ viperInstance .Set (LogLevelKey , "debug" )
308+
309+ log := resolveCollectorLog ()
310+
311+ // Check
312+ assert .Equal (t , "info" , log .Level )
313+ assert .Equal (t , "/tmp/collector.log" , log .Path )
314+ })
315+
316+ t .Run ("Test 2: OTel Log Level Not Set In Config" , func (t * testing.T ) {
317+ viperInstance = viper .NewWithOptions (viper .KeyDelimiter (KeyDelimiter ))
318+ viperInstance .Set (LogLevelKey , "debug" )
319+ viperInstance .Set (CollectorLogPathKey , "/tmp/collector.log" )
320+
321+ log := resolveCollectorLog ()
322+ assert .Equal (t , "debug" , log .Level )
323+ assert .Equal (t , "/tmp/collector.log" , log .Path )
324+ })
325+ }
326+
301327func TestCommand (t * testing.T ) {
302328 viperInstance = viper .NewWithOptions (viper .KeyDelimiter (KeyDelimiter ))
303329 expected := agentConfig ().Command
0 commit comments