feat(discord_test#init): check for oauth2 token
This commit is contained in:
parent
7044ee62cb
commit
3d0ad546d1
1 changed files with 13 additions and 13 deletions
|
@ -15,7 +15,7 @@ var (
|
|||
dg *Session // Stores a global discordgo user session
|
||||
dgBot *Session // Stores a global discordgo bot session
|
||||
|
||||
envToken = os.Getenv("DGU_TOKEN") // Token to use when authenticating the user account
|
||||
envOAuth2Token = os.Getenv("DG_OAUTH2_TOKEN") // Token to use when authenticating using OAuth2 token
|
||||
envBotToken = os.Getenv("DGB_TOKEN") // Token to use when authenticating the bot account
|
||||
envGuild = os.Getenv("DG_GUILD") // Guild ID to use for tests
|
||||
envChannel = os.Getenv("DG_CHANNEL") // Channel ID to use for tests
|
||||
|
@ -30,10 +30,10 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
if d, err := New(envToken); err == nil {
|
||||
if envOAuth2Token != "" {
|
||||
if d, err := New(envOAuth2Token); err == nil {
|
||||
dg = d
|
||||
} else {
|
||||
fmt.Println("dg is nil, error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,11 +43,11 @@ func init() {
|
|||
// TestNewToken tests the New() function with a Token.
|
||||
func TestNewToken(t *testing.T) {
|
||||
|
||||
if envToken == "" {
|
||||
if envOAuth2Token == "" {
|
||||
t.Skip("Skipping New(token), DGU_TOKEN not set")
|
||||
}
|
||||
|
||||
d, err := New(envToken)
|
||||
d, err := New(envOAuth2Token)
|
||||
if err != nil {
|
||||
t.Fatalf("New(envToken) returned error: %+v", err)
|
||||
}
|
||||
|
@ -62,11 +62,11 @@ func TestNewToken(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOpenClose(t *testing.T) {
|
||||
if envToken == "" {
|
||||
if envOAuth2Token == "" {
|
||||
t.Skip("Skipping TestClose, DGU_TOKEN not set")
|
||||
}
|
||||
|
||||
d, err := New(envToken)
|
||||
d, err := New(envOAuth2Token)
|
||||
if err != nil {
|
||||
t.Fatalf("TestClose, New(envToken) returned error: %+v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue