Add test for u/p/token login.

This commit is contained in:
Chris Rhodes 2016-01-20 23:48:30 -08:00
parent 2cbd402bae
commit 7d984e7df6

View file

@ -122,8 +122,7 @@ func TestInvalidPass(t *testing.T) {
}
// 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.
// This should return a valid Session{}, a valid Session.Token.
func TestNewUserPass(t *testing.T) {
if envEmail == "" || envPassword == "" {
@ -167,6 +166,29 @@ func TestNewToken(t *testing.T) {
}
}
// TestNewUserPassToken tests the New() function with a username, password and token.
// This should return the same as the TestNewUserPass function.
func TestNewUserPassToken(t *testing.T) {
if envEmail == "" || envPassword == "" || envToken == "" {
t.Skip("Skipping New(username,password,token), DG_EMAIL, DG_PASSWORD or DG_TOKEN not set")
return
}
d, err := New(envEmail, envPassword, envToken)
if err != nil {
t.Fatalf("New(user,pass,token) returned error: %+v", err)
}
if d == nil {
t.Fatal("New(user,pass,token), d is nil, should be Session{}")
}
if d.Token == "" {
t.Fatal("New(user,pass,token), d.Token is empty, should be a valid Token.")
}
}
func TestOpenClose(t *testing.T) {
if envToken == "" {
t.Skip("Skipping TestClose, DG_TOKEN not set")