Setting logprovider in advance for SDK tests
Some tests directly call SDK api in advance before calling
fabapi.NewSDK() function for testing. Just to make sure
related log lines are not skipped, setting a login provider
in advance in main_test.
@@ -11,6 +11,8 @@ import (
"testing"
config "github.com/hyperledger/fabric-sdk-go/api/apiconfig"
+ "github.com/hyperledger/fabric-sdk-go/pkg/logging"
+ "github.com/hyperledger/fabric-sdk-go/pkg/logging/deflogger"
)
var testFabricConfig config.Config
@@ -23,6 +25,12 @@ func TestMain(m *testing.M) {
}
func setup() {
+
+ //Setup logging provider in advance for tests to make sure none of the test logs are being skipped
+ if !logging.IsLoggerInitialized() {
+ logging.InitLogger(deflogger.GetLoggingProvider())
+ }
+
// do any test setup for all tests here...
var err error
