Browse Source

Added more tests for New() func

Bruce Marriner 9 years ago
parent
commit
77f4199262
1 changed files with 33 additions and 0 deletions
  1. 33 0
      tests/discordgo_test.go

+ 33 - 0
tests/discordgo_test.go

@@ -76,6 +76,39 @@ func TestNew(t *testing.T) {
 	}
 }
 
+// TestInvalidToken tests the New() function with an invalid token
+func TestInvalidToken(t *testing.T) {
+
+	_, err := New("asjkldhflkjasdh")
+	if err == nil {
+		t.Errorf("New(InvalidToken) returned nil error.")
+	}
+
+}
+
+// TestInvalidUserPass tests the New() function with an invalid Email and Pass
+func TestInvalidEmailPass(t *testing.T) {
+
+	_, err := New("invalidemail", "invalidpassword")
+	if err == nil {
+		t.Errorf("New(InvalidEmail, InvalidPass) returned nil error.")
+	}
+
+}
+
+// TestInvalidPass tests the New() function with an invalid Password
+func TestInvalidPass(t *testing.T) {
+
+	if envUsername == "" {
+		t.Skip("Skipping New(username,InvalidPass), DG_USERNAME not set")
+		return
+	}
+	_, err := New(envUsername, "invalidpassword")
+	if err == nil {
+		t.Errorf("New(Email, InvalidPass) returned nil error.")
+	}
+}
+
 // TestNewUserPass tests the New() function with a username and password.
 // This should return a valid Session{}, a valid Session.Token, and open
 // a websocket connection to Discord.