From 30c1649a32906a43b20a8dffb8246aae98d4deaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Henrique=20Guard=C3=A3o=20Gandarez?= Date: Sun, 28 Jul 2024 21:24:28 -0300 Subject: [PATCH] wip --- cmd/fileexperts/fileexperts_test.go | 2 +- cmd/run_internal_test.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/fileexperts/fileexperts_test.go b/cmd/fileexperts/fileexperts_test.go index a18e05d9..aa0f0c08 100644 --- a/cmd/fileexperts/fileexperts_test.go +++ b/cmd/fileexperts/fileexperts_test.go @@ -112,7 +112,7 @@ func TestFileExperts_NonExistingEntity(t *testing.T) { v.Set("log-file", logFile.Name()) v.Set("verbose", true) - cmd.SetupLogging(v) + _, _ = cmd.SetupLogging(v) defer func() { if file, ok := log.Output().(*os.File); ok { diff --git a/cmd/run_internal_test.go b/cmd/run_internal_test.go index 425599cd..5c4a39fe 100644 --- a/cmd/run_internal_test.go +++ b/cmd/run_internal_test.go @@ -15,6 +15,7 @@ import ( cmdheartbeat "github.com/wakatime/wakatime-cli/cmd/heartbeat" "github.com/wakatime/wakatime-cli/pkg/exitcode" "github.com/wakatime/wakatime-cli/pkg/ini" + "github.com/wakatime/wakatime-cli/pkg/log" "github.com/wakatime/wakatime-cli/pkg/version" "github.com/spf13/viper" @@ -111,10 +112,6 @@ func TestRunCmd_ErrOfflineEnqueue(t *testing.T) { } func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is windows.") - } - verbose := true testServerURL, router, tearDown := setupTestServer() @@ -157,6 +154,15 @@ func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { _, _ = SetupLogging(v) + defer func() { + if file, ok := log.Output().(*os.File); ok { + _ = file.Sync() + file.Close() + } else if handler, ok := log.Output().(io.Closer); ok { + handler.Close() + } + }() + err = runCmd(v, verbose, false, cmdheartbeat.Run) var errexitcode exitcode.Err @@ -164,7 +170,6 @@ func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { require.ErrorAs(t, err, &errexitcode) assert.Equal(t, exitcode.ErrBackoff, err.(exitcode.Err).Code) - assert.Equal(t, 0, numCalls) output, err := io.ReadAll(logFile)