// TestMain is run implicitly and only once, before any of the tests defined in this file run.
// It sets up a test gRPC server and establishes connection to the server. This gRPC client
// connection is then re-used in all the tests to reduce overhead.
// Once all the tests run, we close the connection to the server and stop the server.
TestMain is run implicitly and only once, before any of the tests defined in this file run.
It sets up a test gRPC server and establishes connection to the server. This gRPC client
connection is then re-used in all the tests to reduce overhead.
Once all the tests run, we close the connection to the server and stop the server.
// TestMain is run implicitly and only once before any of the tests defined in this file run . // It sets up a test gRPC server and establishes connection to the server . This gRPC client // connection is then re - used in all the tests to reduce overhead . // Once all the tests run we close the connection to the server and stop the server .
func TestMain(m *testing.M) {
	logger, _ := log.NewStdoutLogger("testServer", log.NOTICE, log.FORMAT_LONG)
	server, err := server.NewServer("testdata/server.pem", "testdata/server.key",
		config.LoadRegistrationDBAddress(), logger)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	clientLogger, _ := log.NewStdoutLogger("client", log.NOTICE, log.FORMAT_SHORT)
	SetLogger(clientLogger)
	go server.Start(7008)
	testCert, err := ioutil.ReadFile("testdata/server.pem")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	testGrpcClientConn, err = GetConnection(NewConnectionConfig(testGrpcServerEndpoint, "",
		testCert, 500))
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	returnCode := m.Run()
	server.Teardown()
	testGrpcClientConn.Close()
	os.Exit(returnCode)
}
func TestMain ( m * testing . M ) { logger , _ := log . NewStdoutLogger ( " " , log . NOTICE , log . FORMAT_LONG ) server , err := server . NewServer ( " " , " " , config . LoadRegistrationDBAddress ( ) , logger ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } clientLogger , _ := log . NewStdoutLogger ( " " , log . NOTICE , log . FORMAT_SHORT ) SetLogger ( clientLogger ) go server . Start ( 7008 ) testCert , err := ioutil . ReadFile ( " " ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } testGrpcClientConn , err = GetConnection ( NewConnectionConfig ( testGrpcServerEndpoint , " " , testCert , 500 ) ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } returnCode := m . Run ( ) server . Teardown ( ) testGrpcClientConn . Close ( ) os . Exit ( returnCode ) }
TestMain is run implicitly and only once, before any of the tests defined in this file run.
TestMain is run implicitly and only once before any of the tests defined in this file run .
// Configure a custom logger for the client package // Establish a connection to previously started server // At this point all the tests will actually run // Cleanup - close connection, stop the server and exit