Add test for u/p/token login.
This commit is contained in:
parent
2cbd402bae
commit
7d984e7df6
1 changed files with 24 additions and 2 deletions
|
@ -122,8 +122,7 @@ func TestInvalidPass(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNewUserPass tests the New() function with a username and password.
|
// TestNewUserPass tests the New() function with a username and password.
|
||||||
// This should return a valid Session{}, a valid Session.Token, and open
|
// This should return a valid Session{}, a valid Session.Token.
|
||||||
// a websocket connection to Discord.
|
|
||||||
func TestNewUserPass(t *testing.T) {
|
func TestNewUserPass(t *testing.T) {
|
||||||
|
|
||||||
if envEmail == "" || envPassword == "" {
|
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) {
|
func TestOpenClose(t *testing.T) {
|
||||||
if envToken == "" {
|
if envToken == "" {
|
||||||
t.Skip("Skipping TestClose, DG_TOKEN not set")
|
t.Skip("Skipping TestClose, DG_TOKEN not set")
|
||||||
|
|
Loading…
Reference in a new issue