feat: add tmp test file
This commit is contained in:
parent
b5b1fc4574
commit
42552ba56d
39
console_test.go
Normal file
39
console_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"os"
|
||||
)
|
||||
|
||||
func TestExecInput(t *testing.T) {
|
||||
// 设置测试环境变量
|
||||
os.Setenv("HOME", "/fake/home")
|
||||
|
||||
// 定义测试用例
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
wantErr bool
|
||||
}{
|
||||
{"Help Command", "help", false},
|
||||
{"CD with No Argument", "cd", false},
|
||||
{"CD with Argument", "cd /tmp", false},
|
||||
{"Set with Insufficient Args", "set", true},
|
||||
// 添加更多测试用例...
|
||||
}
|
||||
|
||||
// 执行测试用例
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := execInput(tt.input)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("execInput() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 清除测试环境变量
|
||||
os.Unsetenv("HOME")
|
||||
}
|
||||
|
||||
// 请根据需要定义更多的测试用例来覆盖函数的不同方面。
|
Loading…
x
Reference in New Issue
Block a user