golang - linux 上 which 命令的简单实现 - 单元测试
最编程
2024-04-07 06:59:14
...
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWhich(t *testing.T) {
filepath, _ := Which("sh")
assert.Equal(t, filepath, "/bin/sh")
filepath, err := Which("xxx")
assert.Equal(t, filepath, "")
assert.ErrorContains(t, err, "no such file or directory")
}
下一篇: 自动驾驶中交通标志识别的原理和应用