Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Jul 29, 2024
1 parent 35e88b4 commit b2a5373
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/fileexperts/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 10 additions & 5 deletions cmd/run_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -157,14 +154,22 @@ 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

require.ErrorAs(t, err, &errexitcode)

assert.Equal(t, exitcode.ErrBackoff, err.(exitcode.Err).Code)

assert.Equal(t, 0, numCalls)

output, err := io.ReadAll(logFile)
Expand Down

0 comments on commit b2a5373

Please sign in to comment.