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 191ca6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 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: 11 additions & 4 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,9 +112,7 @@ func TestRunCmd_ErrOfflineEnqueue(t *testing.T) {
}

func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping because OS is windows.")
}
t.Parallel()

verbose := true

Expand Down Expand Up @@ -157,14 +156,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 191ca6c

Please sign in to comment.