From fd8e56c902e60ee393ffc850052cee04ca2d7b59 Mon Sep 17 00:00:00 2001
From: Jono Wenger <jono@elixxir.io>
Date: Fri, 12 Feb 2021 09:48:53 -0800
Subject: [PATCH] Fix interface checking on testing functions

---
 keyExchange/utils_test.go | 12 ++----------
 storage/e2e/session.go    |  6 +-----
 storage/session.go        |  6 +-----
 3 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/keyExchange/utils_test.go b/keyExchange/utils_test.go
index c11728b1a..bda05f0b8 100644
--- a/keyExchange/utils_test.go
+++ b/keyExchange/utils_test.go
@@ -101,11 +101,7 @@ func (t *testNetworkManagerGeneric) GetStoppable() stoppable.Stoppable {
 
 func InitTestingContextGeneric(i interface{}) (*storage.Session, interfaces.NetworkManager) {
 	switch i.(type) {
-	case *testing.T:
-		break
-	case *testing.M:
-		break
-	case *testing.B:
+	case *testing.T, *testing.M, *testing.B, *testing.PB:
 		break
 	default:
 		globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i)
@@ -208,11 +204,7 @@ func (t *testNetworkManagerFullExchange) GetStoppable() stoppable.Stoppable {
 
 func InitTestingContextFullExchange(i interface{}) (*storage.Session, *switchboard.Switchboard, interfaces.NetworkManager) {
 	switch i.(type) {
-	case *testing.T:
-		break
-	case *testing.M:
-		break
-	case *testing.B:
+	case *testing.T, *testing.M, *testing.B, *testing.PB:
 		break
 	default:
 		globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i)
diff --git a/storage/e2e/session.go b/storage/e2e/session.go
index 43eacbf80..78997dc00 100644
--- a/storage/e2e/session.go
+++ b/storage/e2e/session.go
@@ -243,11 +243,7 @@ func getSessionIDFromBaseKey(baseKey *cyclic.Int) SessionID {
 // FOR TESTING PURPOSES ONLY
 func GetSessionIDFromBaseKeyForTesting(baseKey *cyclic.Int, i interface{}) SessionID {
 	switch i.(type) {
-	case *testing.T:
-		break
-	case *testing.M:
-		break
-	case *testing.B:
+	case *testing.T, *testing.M, *testing.B, *testing.PB:
 		break
 	default:
 		globals.Log.FATAL.Panicf("GetSessionIDFromBaseKeyForTesting is restricted to testing only. Got %T", i)
diff --git a/storage/session.go b/storage/session.go
index 8f276039d..ab8d23d99 100644
--- a/storage/session.go
+++ b/storage/session.go
@@ -290,11 +290,7 @@ func (s *Session) Delete(key string) error {
 // FOR TESTING ONLY
 func InitTestingSession(i interface{}) *Session {
 	switch i.(type) {
-	case *testing.T:
-		break
-	case *testing.M:
-		break
-	case *testing.B:
+	case *testing.T, *testing.M, *testing.B, *testing.PB:
 		break
 	default:
 		globals.Log.FATAL.Panicf("InitTestingSession is restricted to testing only. Got %T", i)
-- 
GitLab