diff --git a/cmd/heartbeat/heartbeat_test.go b/cmd/heartbeat/heartbeat_test.go index 818e88b3..11f48d45 100644 --- a/cmd/heartbeat/heartbeat_test.go +++ b/cmd/heartbeat/heartbeat_test.go @@ -847,8 +847,13 @@ func TestSendHeartbeats_ErrBackoff(t *testing.T) { defer logFile.Close() - v := viper.New() + tmpFile, err := os.CreateTemp(tmpDir, "wakatime") + require.NoError(t, err) + + defer tmpFile.Close() + v := viper.New() + v.Set("internal-config", tmpFile.Name()) v.Set("internal.backoff_at", time.Now().Add(10*time.Minute).Format(ini.DateFormat)) v.Set("internal.backoff_retries", "1") v.SetDefault("sync-offline-activity", 1000) @@ -912,8 +917,13 @@ func TestSendHeartbeats_ErrBackoff_Verbose(t *testing.T) { defer logFile.Close() - v := viper.New() + tmpFile, err := os.CreateTemp(tmpDir, "wakatime") + require.NoError(t, err) + + defer tmpFile.Close() + v := viper.New() + v.Set("internal-config", tmpFile.Name()) v.Set("internal.backoff_at", time.Now().Add(10*time.Minute).Format(ini.DateFormat)) v.Set("internal.backoff_retries", "1") v.SetDefault("sync-offline-activity", 1000) diff --git a/cmd/offlinesync/offlinesync_test.go b/cmd/offlinesync/offlinesync_test.go index cad6f803..8e717624 100644 --- a/cmd/offlinesync/offlinesync_test.go +++ b/cmd/offlinesync/offlinesync_test.go @@ -210,9 +210,15 @@ func TestRunWithoutRateLimiting(t *testing.T) { func TestRunWithRateLimiting_RateLimited(t *testing.T) { resetSingleton(t) + tmpFile, err := os.CreateTemp(t.TempDir(), "wakatime") + require.NoError(t, err) + + defer tmpFile.Close() + v := viper.New() v.Set("key", "00000000-0000-4000-8000-000000000000") v.Set("heartbeat-rate-limit-seconds", 500) + v.Set("internal-config", tmpFile.Name()) v.Set("internal.heartbeats_last_sent_at", time.Now().Add(-time.Minute).Format(time.RFC3339)) code, err := offlinesync.RunWithRateLimiting(v) diff --git a/cmd/run_internal_test.go b/cmd/run_internal_test.go index 425599cd..cc05a604 100644 --- a/cmd/run_internal_test.go +++ b/cmd/run_internal_test.go @@ -8,7 +8,6 @@ import ( "net/http" "net/http/httptest" "os" - "runtime" "testing" "time" @@ -111,10 +110,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() @@ -135,6 +130,11 @@ func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { defer logFile.Close() + tmpFile, err := os.CreateTemp(tmpDir, "wakatime") + require.NoError(t, err) + + defer tmpFile.Close() + offlineQueueFile, err := os.CreateTemp(tmpDir, "") require.NoError(t, err) @@ -151,6 +151,7 @@ func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { v.Set("key", "00000000-0000-4000-8000-000000000000") v.Set("log-file", logFile.Name()) v.Set("offline-queue-file", offlineQueueFile.Name()) + v.Set("internal-config", tmpFile.Name()) v.Set("internal.backoff_at", time.Now().Add(10*time.Minute).Format(ini.DateFormat)) v.Set("internal.backoff_retries", "1") v.Set("verbose", verbose) @@ -174,10 +175,6 @@ func TestRunCmd_BackoffLoggedWithVerbose(t *testing.T) { } func TestRunCmd_BackoffNotLogged(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is windows.") - } - verbose := false testServerURL, router, tearDown := setupTestServer() @@ -203,6 +200,11 @@ func TestRunCmd_BackoffNotLogged(t *testing.T) { defer logFile.Close() + tmpFile, err := os.CreateTemp(tmpDir, "wakatime") + require.NoError(t, err) + + defer tmpFile.Close() + entity, err := os.CreateTemp(tmpDir, "") require.NoError(t, err) @@ -214,6 +216,7 @@ func TestRunCmd_BackoffNotLogged(t *testing.T) { v.Set("key", "00000000-0000-4000-8000-000000000000") v.Set("log-file", logFile.Name()) v.Set("offline-queue-file", offlineQueueFile.Name()) + v.Set("internal-config", tmpFile.Name()) v.Set("internal.backoff_at", time.Now().Add(10*time.Minute).Format(ini.DateFormat)) v.Set("internal.backoff_retries", "1") v.Set("verbose", verbose) diff --git a/pkg/project/tfvc_test.go b/pkg/project/tfvc_test.go index 6e79b9a5..77525367 100644 --- a/pkg/project/tfvc_test.go +++ b/pkg/project/tfvc_test.go @@ -14,10 +14,6 @@ import ( ) func TestTfvc_Detect(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is windows.") - } - fp := setupTestTfvc(t, ".tf") s := project.Tfvc{ diff --git a/pkg/remote/remote_test.go b/pkg/remote/remote_test.go index 2215e4ee..b1385e7f 100644 --- a/pkg/remote/remote_test.go +++ b/pkg/remote/remote_test.go @@ -9,7 +9,6 @@ import ( "os" "path/filepath" "regexp" - "runtime" "strconv" "strings" "testing" @@ -64,10 +63,6 @@ func TestNewClient_Err(t *testing.T) { } func TestWithDetection_SshConfig_Hostname(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is Windows.") - } - shutdown, host, port := testServer(t, false) defer shutdown() @@ -133,10 +128,6 @@ func TestWithDetection_SshConfig_Hostname(t *testing.T) { } func TestWithDetection_SshConfig_UserKnownHostsFile_Mismatch(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is Windows.") - } - logs := bytes.NewBuffer(nil) teardownLogCapture := captureLogs(logs) @@ -199,10 +190,6 @@ func TestWithDetection_SshConfig_UserKnownHostsFile_Mismatch(t *testing.T) { } func TestWithDetection_SshConfig_UserKnownHostsFile_Match(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is Windows.") - } - logs := bytes.NewBuffer(nil) teardownLogCapture := captureLogs(logs) @@ -282,10 +269,6 @@ func TestWithDetection_SshConfig_UserKnownHostsFile_Match(t *testing.T) { } func TestWithDetection_Filtered(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("Skipping because OS is Windows.") - } - logs := bytes.NewBuffer(nil) teardownLogCapture := captureLogs(logs)