summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-15 16:44:30 +1000
committerGitHub <noreply@github.com>2023-07-15 16:44:30 +1000
commit5adea789d02c8a59954bda1e234a596d688c8c5c (patch)
tree0999f7ca06c363b8d7b6515b7c1e58ed8a553c0a
parent5cb82a49f893bced697148d259595d582d71a742 (diff)
parent78bbdca7572df560dc3bc2d76cfb855366270dbc (diff)
Add test for cmd obj cloning (#2780)
-rw-r--r--pkg/commands/oscommands/cmd_obj_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/commands/oscommands/cmd_obj_test.go b/pkg/commands/oscommands/cmd_obj_test.go
index dc04311a3..c9cb92eb5 100644
--- a/pkg/commands/oscommands/cmd_obj_test.go
+++ b/pkg/commands/oscommands/cmd_obj_test.go
@@ -1,7 +1,10 @@
package oscommands
import (
+ "os/exec"
"testing"
+
+ "github.com/jesseduffield/gocui"
)
func TestCmdObjToString(t *testing.T) {
@@ -31,3 +34,20 @@ func TestCmdObjToString(t *testing.T) {
}
}
}
+
+func TestClone(t *testing.T) {
+ task := gocui.NewFakeTask()
+ cmdObj := &CmdObj{task: task, cmd: &exec.Cmd{}}
+ clone := cmdObj.Clone()
+ if clone == cmdObj {
+ t.Errorf("Clone should not return the same object")
+ }
+
+ if clone.GetTask() == nil {
+ t.Errorf("Clone task should not be nil")
+ }
+
+ if clone.GetTask() != task {
+ t.Errorf("Clone should have the same task")
+ }
+}