diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-25 11:10:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-25 11:10:52 +0300 |
| commit | 541fe26ddb20e00112d0bcbda9249625dfe5d245 (patch) | |
| tree | 5f81675f24bfbb0dc9256cfdf8ce70b319c7fd35 | |
| parent | f3b64f706e2df8ceffafdef916a127e8e22c296b (diff) | |
Fix gofmt and errcheck guardrails for task 2r0
| -rw-r--r-- | Magefile.go | 20 | ||||
| -rw-r--r-- | internal/task/operations_test.go | 10 | ||||
| -rw-r--r-- | internal/task/task_test.go | 34 | ||||
| -rw-r--r-- | internal/ui/table_test.go | 280 |
4 files changed, 183 insertions, 161 deletions
diff --git a/Magefile.go b/Magefile.go index b4b5ecc..1f4f1cc 100644 --- a/Magefile.go +++ b/Magefile.go @@ -6,6 +6,7 @@ package main import ( "fmt" "os" + "strings" "github.com/magefile/mage/sh" ) @@ -34,6 +35,25 @@ func Test() error { return sh.Run("go", "test", "./...") } +// Verify runs formatting and static checks before tests. +func Verify() error { + fmt.Println("Checking gofmt...") + out, err := sh.Output("gofmt", "-l", ".") + if err != nil { + return err + } + if strings.TrimSpace(out) != "" { + return fmt.Errorf("gofmt needed for:\n%s", out) + } + + fmt.Println("Running errcheck...") + if err := sh.Run("errcheck", "./..."); err != nil { + return err + } + + return Test() +} + // Install installs tasksamurai to $GOPATH/bin func Install() error { fmt.Println("Installing tasksamurai...") diff --git a/internal/task/operations_test.go b/internal/task/operations_test.go index 7abd4bd..bd2fc44 100644 --- a/internal/task/operations_test.go +++ b/internal/task/operations_test.go @@ -38,7 +38,7 @@ func TestModifyTask(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := modifyTask(tt.id, tt.args...) - + // We can't test actual taskwarrior commands without it installed // So we just test the validation if tt.wantErr { @@ -85,7 +85,7 @@ func TestSimpleTaskCommand(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := simpleTaskCommand(tt.id, tt.command) - + // We can't test actual taskwarrior commands without it installed // So we just test the validation if tt.wantErr { @@ -102,7 +102,7 @@ func TestSimpleTaskCommand(t *testing.T) { func TestTaskOperationsValidation(t *testing.T) { // Test that all task operations validate IDs invalidID := -1 - + operations := []struct { name string fn func() error @@ -119,7 +119,7 @@ func TestTaskOperationsValidation(t *testing.T) { {"Annotate", func() error { return Annotate(invalidID, "note") }}, {"Denotate", func() error { return Denotate(invalidID, "note") }}, } - + for _, op := range operations { t.Run(op.name, func(t *testing.T) { err := op.fn() @@ -130,4 +130,4 @@ func TestTaskOperationsValidation(t *testing.T) { } }) } -}
\ No newline at end of file +} diff --git a/internal/task/task_test.go b/internal/task/task_test.go index 556351f..f4567ba 100644 --- a/internal/task/task_test.go +++ b/internal/task/task_test.go @@ -17,7 +17,7 @@ import ( // target directory does not exist. func TestSetDebugLog(t *testing.T) { // Ensure the package-level state is clean before and after. - t.Cleanup(func() { SetDebugLog("") }) //nolint:errcheck + t.Cleanup(func() { _ = SetDebugLog("") }) // Negative: directory does not exist — must return an error. if err := SetDebugLog("/nonexistent-dir-xyz/debug.log"); err == nil { @@ -40,7 +40,9 @@ func TestSetDebugLog(t *testing.T) { // The run helper uses dbg.writer — verify that a write actually reaches // the log file. We fake a task invocation by writing directly. - fmt.Fprintln(dbg.writer, "test-entry") + if _, err := fmt.Fprintln(dbg.writer, "test-entry"); err != nil { + t.Fatalf("write debug log: %v", err) + } content, err := os.ReadFile(logPath) if err != nil { t.Fatalf("read log file: %v", err) @@ -79,8 +81,8 @@ func TestAddAndExport(t *testing.T) { t.Fatal(err) } t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) if err := Add("hello world", []string{"tag", "anothertag", "tasksamuraitesting"}); err != nil { @@ -134,8 +136,8 @@ func TestRunLineSplitsCapturesAndStripsTaskPrefix(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) result, err := RunLine(context.Background(), `task add "hello world" project:home`) if err != nil { @@ -171,8 +173,8 @@ func TestRunShellLineDisablesRecurrencePrompt(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) if _, err := RunShellLine(context.Background(), `task 260 modify project:foo`); err != nil { t.Fatalf("RunShellLine: %v", err) @@ -200,8 +202,8 @@ func TestRunLineReturnsCapturedErrorOutput(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) result, err := RunLine(context.Background(), "bad command") if err == nil { @@ -737,8 +739,8 @@ func TestLoadCompletionSources(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) sources := LoadCompletionSources(context.Background()) if strings.Join(sources.Commands, ",") != "add,modify" { @@ -782,8 +784,8 @@ func TestRecurringSeries(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) tasks, err := RecurringSeries(context.Background(), "parent-uuid") if err != nil { @@ -820,8 +822,8 @@ func TestModifyHelpers(t *testing.T) { t.Fatal(err) } t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) if err := Add("hello", nil); err != nil { diff --git a/internal/ui/table_test.go b/internal/ui/table_test.go index 14e78ca..7a8a186 100644 --- a/internal/ui/table_test.go +++ b/internal/ui/table_test.go @@ -261,14 +261,14 @@ func TestAnnotateHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -367,14 +367,14 @@ func TestReplaceAnnotationHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -429,14 +429,14 @@ func TestHandleDescEditDoneUpdatesDescriptionAndRemovesTempFile(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -485,8 +485,8 @@ func TestEditDescriptionCmdPreparesLaunchWithoutRunningEditor(t *testing.T) { } origEditor := os.Getenv("EDITOR") - os.Setenv("EDITOR", editorPath) - t.Cleanup(func() { os.Setenv("EDITOR", origEditor) }) + _ = os.Setenv("EDITOR", editorPath) + t.Cleanup(func() { _ = os.Setenv("EDITOR", origEditor) }) cmd := editDescriptionCmd("old description") msg := cmd() @@ -601,14 +601,14 @@ func TestHandleFilterModeReportsReloadError(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -657,14 +657,14 @@ func TestDoneHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -707,14 +707,14 @@ func TestUndoHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -767,14 +767,14 @@ func TestDeleteHotkeyUndo(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -826,14 +826,14 @@ func TestDeleteRecurringHotkeyUndo(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -994,14 +994,14 @@ func TestDeleteHotkeyInUltraMode(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1040,14 +1040,14 @@ func TestDeleteHotkeyInDetailMode(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1097,14 +1097,14 @@ func TestOpenURLHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, browserPath) @@ -1161,14 +1161,14 @@ func TestDueDateHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1215,14 +1215,14 @@ func TestRandomDueDateHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1270,14 +1270,14 @@ func TestRecurrenceHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1460,14 +1460,14 @@ func TestPriorityHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1508,14 +1508,14 @@ func TestAddHotkey(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1560,14 +1560,14 @@ func TestNavigationHotkeys(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1657,14 +1657,14 @@ func TestAgentFilterHotkeyDefaultsToThree(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1696,14 +1696,14 @@ func TestAgentFilterHotkeyCanBeRebound(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New([]string{"project:home"}, "firefox") @@ -1752,14 +1752,14 @@ func TestAgentFilterHotkeyNamedKeysAreCanonicalized(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1802,14 +1802,14 @@ func TestAgentFilterHotkeyRejectsUppercaseNamedKeyCollision(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -1853,14 +1853,14 @@ func TestAgentFilterHotkeyCollisionIsRejected(t *testing.T) { } origPath := os.Getenv("PATH") - os.Setenv("PATH", tmp+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", tmp+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) m, err := New(nil, "firefox") @@ -2036,15 +2036,15 @@ func setupSharedSearchTaskSet(t *testing.T, tmp string) string { func setupEnv(t *testing.T, taskPath string) { origPath := os.Getenv("PATH") - os.Setenv("PATH", filepath.Dir(taskPath)+":"+origPath) - t.Cleanup(func() { os.Setenv("PATH", origPath) }) + _ = os.Setenv("PATH", filepath.Dir(taskPath)+":"+origPath) + t.Cleanup(func() { _ = os.Setenv("PATH", origPath) }) tmp := filepath.Dir(taskPath) - os.Setenv("TASKDATA", tmp) - os.Setenv("TASKRC", "/dev/null") + _ = os.Setenv("TASKDATA", tmp) + _ = os.Setenv("TASKRC", "/dev/null") t.Cleanup(func() { - os.Unsetenv("TASKDATA") - os.Unsetenv("TASKRC") + _ = os.Unsetenv("TASKDATA") + _ = os.Unsetenv("TASKRC") }) } |
