Browse Source

feat(discord_test): rewrote init as TestMain

nitroflap 3 years ago
parent
commit
12b412a989
1 changed files with 3 additions and 1 deletions
  1. 3 1
      discord_test.go

+ 3 - 1
discord_test.go

@@ -22,7 +22,7 @@ var (
 	envAdmin       = os.Getenv("DG_ADMIN")        // User ID of admin user to use for tests
 )
 
-func init() {
+func TestMain(m *testing.M) {
 	fmt.Println("Init is being called.")
 	if envBotToken != "" {
 		if d, err := New(envBotToken); err == nil {
@@ -35,6 +35,8 @@ func init() {
 			dg = d
 		}
 	}
+
+	os.Exit(m.Run())
 }
 
 //////////////////////////////////////////////////////////////////////////////