✅ 添加 projects 测试
This commit is contained in:
parent
3a248d6ec9
commit
c1ae962193
30
main_test.go
30
main_test.go
|
@ -1,11 +1,41 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/xuxiaowei-com-cn/git-go/buildinfo"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_CommitSha(t *testing.T) {
|
||||
fmt.Println(buildinfo.CommitSha())
|
||||
}
|
||||
|
||||
func Test_Projects(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
// 不带参数的测试输出
|
||||
os.Args = []string{"cmd"}
|
||||
main()
|
||||
if got := buf.String(); !strings.Contains(got, "") {
|
||||
t.Errorf("异常信息:\n%s", got)
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
|
||||
// 使用版本参数测试输出
|
||||
os.Args = []string{"cmd", "projects"}
|
||||
main()
|
||||
if got := buf.String(); !strings.Contains(got, "") {
|
||||
t.Errorf("异常信息:\n%s", got)
|
||||
}
|
||||
|
||||
// 使用版本参数测试输出
|
||||
os.Args = []string{"cmd", "p"}
|
||||
main()
|
||||
if got := buf.String(); !strings.Contains(got, "") {
|
||||
t.Errorf("异常信息:\n%s", got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue