github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/updater/service/logger_test.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package main
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/keybase/client/go/updater/keybase"
    10  	"github.com/keybase/client/go/updater/util"
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestLoggerNil(t *testing.T) {
    15  	log := logger{}
    16  	log.Debug(nil)
    17  	log.Debugf("")
    18  	log.Info(nil)
    19  	log.Infof("")
    20  	log.Warning(nil)
    21  	log.Warningf("")
    22  	log.Error(nil)
    23  	log.Errorf("")
    24  }
    25  
    26  func TestLoggerFile(t *testing.T) {
    27  	log := logger{}
    28  
    29  	dir, err := keybase.LogDir("KeybaseTest")
    30  	require.NoError(t, err)
    31  	if exists, _ := util.FileExists(dir); !exists {
    32  		t.Logf("Creating %s", dir)
    33  		dirErr := util.MakeDirs(dir, 0700, testLog)
    34  		require.NoError(t, dirErr)
    35  		defer util.RemoveFileAtPath(dir)
    36  	}
    37  
    38  	_, path, err := log.setLogToFile("KeybaseTest", "TestLoggerFile.log")
    39  	defer util.RemoveFileAtPath(path)
    40  	require.NoError(t, err)
    41  	log.Debug("test")
    42  }