Remove tests against email/password.
This commit is contained in:
parent
e6ed3d579b
commit
0d2878bac4
2 changed files with 14 additions and 87 deletions
|
@ -1,6 +1,7 @@
|
||||||
package discordgo
|
package discordgo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -14,29 +15,25 @@ var (
|
||||||
dg *Session // Stores a global discordgo user session
|
dg *Session // Stores a global discordgo user session
|
||||||
dgBot *Session // Stores a global discordgo bot session
|
dgBot *Session // Stores a global discordgo bot session
|
||||||
|
|
||||||
envToken = os.Getenv("DG_TOKEN") // Token to use when authenticating the user account
|
envToken = os.Getenv("DGU_TOKEN") // Token to use when authenticating the user account
|
||||||
envBotToken = os.Getenv("DGB_TOKEN") // Token to use when authenticating the bot account
|
envBotToken = os.Getenv("DGB_TOKEN") // Token to use when authenticating the bot account
|
||||||
envEmail = os.Getenv("DG_EMAIL") // Email to use when authenticating
|
envGuild = os.Getenv("DG_GUILD") // Guild ID to use for tests
|
||||||
envPassword = os.Getenv("DG_PASSWORD") // Password to use when authenticating
|
envChannel = os.Getenv("DG_CHANNEL") // Channel ID to use for tests
|
||||||
envGuild = os.Getenv("DG_GUILD") // Guild ID to use for tests
|
envAdmin = os.Getenv("DG_ADMIN") // User ID of admin user to use for tests
|
||||||
envChannel = os.Getenv("DG_CHANNEL") // Channel ID to use for tests
|
|
||||||
// envUser = os.Getenv("DG_USER") // User ID to use for tests
|
|
||||||
envAdmin = os.Getenv("DG_ADMIN") // User ID of admin user to use for tests
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
fmt.Println("Init is being called.")
|
||||||
if envBotToken != "" {
|
if envBotToken != "" {
|
||||||
if d, err := New(envBotToken); err == nil {
|
if d, err := New(envBotToken); err == nil {
|
||||||
dgBot = d
|
dgBot = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if envEmail == "" || envPassword == "" || envToken == "" {
|
if d, err := New(envToken); err == nil {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if d, err := New(envEmail, envPassword, envToken); err == nil {
|
|
||||||
dg = d
|
dg = d
|
||||||
|
} else {
|
||||||
|
fmt.Println("dg is nil, error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,58 +64,11 @@ func TestInvalidToken(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestInvalidUserPass tests the New() function with an invalid Email and Pass
|
// TestNewToken tests the New() function with a Token.
|
||||||
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 envEmail == "" {
|
|
||||||
t.Skip("Skipping New(username,InvalidPass), DG_EMAIL not set")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err := New(envEmail, "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.
|
|
||||||
func TestNewUserPass(t *testing.T) {
|
|
||||||
|
|
||||||
if envEmail == "" || envPassword == "" {
|
|
||||||
t.Skip("Skipping New(username,password), DG_EMAIL or DG_PASSWORD not set")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
d, err := New(envEmail, envPassword)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("New(user,pass) returned error: %+v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if d == nil {
|
|
||||||
t.Fatal("New(user,pass), d is nil, should be Session{}")
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.Token == "" {
|
|
||||||
t.Fatal("New(user,pass), d.Token is empty, should be a valid Token.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestNewToken tests the New() function with a Token. This should return
|
|
||||||
// the same as the TestNewUserPass function.
|
|
||||||
func TestNewToken(t *testing.T) {
|
func TestNewToken(t *testing.T) {
|
||||||
|
|
||||||
if envToken == "" {
|
if envToken == "" {
|
||||||
t.Skip("Skipping New(token), DG_TOKEN not set")
|
t.Skip("Skipping New(token), DGU_TOKEN not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := New(envToken)
|
d, err := New(envToken)
|
||||||
|
@ -135,32 +85,9 @@ 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, DGU_TOKEN not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
d, err := New(envToken)
|
d, err := New(envToken)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func ExampleApplication() {
|
func ExampleApplication() {
|
||||||
|
|
||||||
// Authentication Token pulled from environment variable DG_TOKEN
|
// Authentication Token pulled from environment variable DG_TOKEN
|
||||||
Token := os.Getenv("DG_TOKEN")
|
Token := os.Getenv("DGU_TOKEN")
|
||||||
if Token == "" {
|
if Token == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue