From 0f41bc6a653b55c36b269c3f9656da2ac667dc56 Mon Sep 17 00:00:00 2001 From: ouqiang Date: Thu, 23 Mar 2017 09:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0utils=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/utils/utils_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/utils/utils_test.go diff --git a/modules/utils/utils_test.go b/modules/utils/utils_test.go new file mode 100644 index 0000000..f6318dc --- /dev/null +++ b/modules/utils/utils_test.go @@ -0,0 +1,31 @@ +package utils + +import "testing" + +func TestExecShell(t *testing.T) { + _, err := ExecShell("ls") + if err != nil { + t.Fatal(err) + } +} + +func TestRandString(t *testing.T) { + str := RandString(32) + if len(str) != 32 { + t.Fatalf("长度不匹配,目标长度32, 实际%d-%s", len(str), str) + } +} + +func TestMd5(t *testing.T) { + str := Md5("123456") + if len(str) != 32 { + t.Fatalf("长度不匹配,目标长度32, 实际%d-%s", len(str), str) + } +} + +func TestRandNumber(t *testing.T) { + num := RandNumber(10000) + if num <= 0 && num >= 10000 { + t.Fatalf("随机数不在有效范围内-%d", num) + } +} \ No newline at end of file