From 52de068f71abe5b1219ad1b8430d7036f46ef7f1 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Sat, 9 Jan 2016 14:43:43 -0600 Subject: [PATCH] Tests now also check that New(User,Pass) works. --- tests/discordgo_test.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/discordgo_test.go b/tests/discordgo_test.go index d736cd9..304065c 100644 --- a/tests/discordgo_test.go +++ b/tests/discordgo_test.go @@ -81,14 +81,31 @@ func TestNew(t *testing.T) { // a websocket connection to Discord. func TestNewUserPass(t *testing.T) { - if isConnected() { - t.Skip("Skipping New(username,password), already connected.") - } - if envUsername == "" || envPassword == "" { t.Skip("Skipping New(username,password), DG_USERNAME or DG_PASSWORD not set") return } + + d, err := New(envUsername, 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.") + } + + if !waitBoolEqual(10*time.Second, &d.DataReady, true) { + t.Fatal("New(user,pass), d.DataReady is false after 10 seconds. Should be true.") + } + + t.Log("Successfully connected to Discord via New(user,pass).") + dg = d + // Not testing yet. } @@ -96,10 +113,6 @@ func TestNewUserPass(t *testing.T) { // the same as the TestNewUserPass function. func TestNewToken(t *testing.T) { - if isConnected() { - t.Skip("Skipping New(token), already connected.") - } - if envToken == "" { t.Skip("Skipping New(token), DG_TOKEN not set") } @@ -121,7 +134,7 @@ func TestNewToken(t *testing.T) { t.Fatal("New(envToken), d.DataReady is false after 10 seconds. Should be true.") } - t.Log("Successfully connected to Discord.") + t.Log("Successfully connected to Discord via New(token).") dg = d }