提交 c1ae9621 编写于 作者: 徐晓伟's avatar 徐晓伟

添加 projects 测试

上级 3a248d6e
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)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册