mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
test: improve test case
This commit is contained in:
parent
a52e77f6ed
commit
8ed55e1288
2
Makefile
2
Makefile
@ -18,4 +18,4 @@ frpc:
|
|||||||
GOPATH=$(NEW_GOPATH) godep go build -o bin/frpc ./src/frp/cmd/frpc
|
GOPATH=$(NEW_GOPATH) godep go build -o bin/frpc ./src/frp/cmd/frpc
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@GOPATH=$(NEW_GOPATH) godep go test ./...
|
@GOPATH=$(NEW_GOPATH) godep go test -v ./...
|
||||||
|
@ -29,7 +29,7 @@ var (
|
|||||||
func TestBroadcast(t *testing.T) {
|
func TestBroadcast(t *testing.T) {
|
||||||
b := NewBroadcast()
|
b := NewBroadcast()
|
||||||
if b == nil {
|
if b == nil {
|
||||||
t.Errorf("New Broadcast error, nil return")
|
t.Fatalf("New Broadcast error, nil return")
|
||||||
}
|
}
|
||||||
defer b.Close()
|
defer b.Close()
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func TestBroadcast(t *testing.T) {
|
|||||||
|
|
||||||
wait.Wait()
|
wait.Wait()
|
||||||
if succNum != totalNum {
|
if succNum != totalNum {
|
||||||
t.Errorf("TotalNum %d, FailNum(timeout) %d", totalNum, totalNum-succNum)
|
t.Fatalf("TotalNum %d, FailNum(timeout) %d", totalNum, totalNum-succNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func TestEncrypto(t *testing.T) {
|
|||||||
pp.Init([]byte("Hana"))
|
pp.Init([]byte("Hana"))
|
||||||
res, err := pp.Encrypto([]byte("Just One Test!"))
|
res, err := pp.Encrypto([]byte("Just One Test!"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatalf(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[%x]\n", res)
|
fmt.Printf("[%x]\n", res)
|
||||||
@ -36,12 +36,12 @@ func TestDecrypto(t *testing.T) {
|
|||||||
pp.Init([]byte("Hana"))
|
pp.Init([]byte("Hana"))
|
||||||
res, err := pp.Encrypto([]byte("Just One Test!"))
|
res, err := pp.Encrypto([]byte("Just One Test!"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatalf(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err = pp.Decrypto(res)
|
res, err = pp.Decrypto(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatalf(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[%s]\n", string(res))
|
fmt.Printf("[%s]\n", string(res))
|
||||||
|
@ -25,22 +25,22 @@ func TestFull(t *testing.T) {
|
|||||||
version := Full()
|
version := Full()
|
||||||
arr := strings.Split(version, ".")
|
arr := strings.Split(version, ".")
|
||||||
if len(arr) != 3 {
|
if len(arr) != 3 {
|
||||||
t.Errorf("Version string error: %s", version)
|
t.Fatalf("Version string error: %s", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
proto, err := strconv.ParseInt(arr[0], 10, 64)
|
proto, err := strconv.ParseInt(arr[0], 10, 64)
|
||||||
if err != nil || proto < 0 {
|
if err != nil || proto < 0 {
|
||||||
t.Errorf("Version proto error")
|
t.Fatalf("Version proto error")
|
||||||
}
|
}
|
||||||
|
|
||||||
major, err := strconv.ParseInt(arr[1], 10, 64)
|
major, err := strconv.ParseInt(arr[1], 10, 64)
|
||||||
if err != nil || major < 0 {
|
if err != nil || major < 0 {
|
||||||
t.Errorf("Version major error")
|
t.Fatalf("Version major error")
|
||||||
}
|
}
|
||||||
|
|
||||||
minor, err := strconv.ParseInt(arr[2], 10, 64)
|
minor, err := strconv.ParseInt(arr[2], 10, 64)
|
||||||
if err != nil || minor < 0 {
|
if err != nil || minor < 0 {
|
||||||
t.Errorf("Version minor error")
|
t.Fatalf("Version minor error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +51,6 @@ func TestVersion(t *testing.T) {
|
|||||||
parseVerion := fmt.Sprintf("%d.%d.%d", proto, major, minor)
|
parseVerion := fmt.Sprintf("%d.%d.%d", proto, major, minor)
|
||||||
version := Full()
|
version := Full()
|
||||||
if parseVerion != version {
|
if parseVerion != version {
|
||||||
t.Errorf("Get version incorrect, version [%s], parseVerion [%s]", version, parseVerion)
|
t.Fatalf("Get version incorrect, version [%s], parseVerion [%s]", version, parseVerion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user