浏览代码

Add tests for timeout and wrong login.

Julien Laffaye 10 年之前
父节点
当前提交
d640995c66
共有 1 个文件被更改,包括 30 次插入1 次删除
  1. 30 1
      client_test.go

+ 30 - 1
client_test.go

@@ -180,7 +180,6 @@ func TestMultiline(t *testing.T) {
 	c.Quit()
 }
 
-// antioche.antioche.eu.org with IPv6
 func TestConnIPv6(t *testing.T) {
 	if testing.Short() {
 		t.Skip("skipping test in short mode.")
@@ -203,3 +202,33 @@ func TestConnIPv6(t *testing.T) {
 
 	c.Quit()
 }
+
+func TestTimeout(t *testing.T) {
+	if testing.Short() {
+		t.Skip("skipping test in short mode.")
+	}
+
+	c, err := DialTimeout("localhost:2121", 1*time.Second)
+	if err == nil {
+		t.Fatal("expected timeout, got nil error")
+		c.Quit()
+	}
+}
+
+func TestWrongLogin(t *testing.T) {
+	if testing.Short() {
+		t.Skip("skipping test in short mode.")
+	}
+
+	c, err := DialTimeout("localhost:21", 5*time.Second)
+	if err != nil {
+		t.Fatal(err)
+	}
+	defer c.Quit()
+
+	err = c.Login("zoo2Shia", "fei5Yix9")
+	if err == nil {
+		t.Fatal("expected error, got nil")
+	}
+}
+