@@ -18,13 +18,16 @@ package logging
18
18
19
19
import (
20
20
"fmt"
21
+ "os"
21
22
"testing"
22
23
"time"
23
24
24
- "github.com/algorand/go-deadlock"
25
25
"github.com/sirupsen/logrus"
26
26
"github.com/stretchr/testify/require"
27
27
28
+ "github.com/algorand/go-deadlock"
29
+
30
+ "github.com/algorand/go-algorand/config"
28
31
"github.com/algorand/go-algorand/logging/telemetryspec"
29
32
)
30
33
@@ -315,3 +318,21 @@ func TestLogHistoryLevels(t *testing.T) {
315
318
a .Nil (data [5 ]["log" ]) // Panic - this is stack trace
316
319
a .NotNil (data [6 ]["log" ]) // Panic
317
320
}
321
+
322
+ func TestReadTelemetryConfigOrDefaultNoDataDir (t * testing.T ) {
323
+ a := require .New (t )
324
+ tempDir := os .TempDir ()
325
+ originalGlobalConfigFileRoot , _ := config .GetGlobalConfigFileRoot ()
326
+ config .SetGlobalConfigFileRoot (tempDir )
327
+
328
+ cfg , err := ReadTelemetryConfigOrDefault ("" , "" )
329
+ defaultCfgSettings := createTelemetryConfig ()
330
+ config .SetGlobalConfigFileRoot (originalGlobalConfigFileRoot )
331
+
332
+ a .Nil (err )
333
+ a .NotNil (cfg )
334
+ a .NotEqual (TelemetryConfig {}, cfg )
335
+ a .Equal (defaultCfgSettings .UserName , cfg .UserName )
336
+ a .Equal (defaultCfgSettings .Password , cfg .Password )
337
+ a .Equal (len (defaultCfgSettings .GUID ), len (cfg .GUID ))
338
+ }
0 commit comments