2023-03-17 11:20:09 +03:00
|
|
|
package nats_connect
|
|
|
|
|
|
|
|
|
|
import (
|
2023-04-25 17:28:10 +03:00
|
|
|
"github.com/manyakrus/starter/config"
|
|
|
|
|
"github.com/manyakrus/starter/contextmain"
|
|
|
|
|
"github.com/manyakrus/starter/micro"
|
2023-03-17 11:20:09 +03:00
|
|
|
"testing"
|
2023-04-25 17:28:10 +03:00
|
|
|
//"github.com/manyakrus/starter/common/v0/logger"
|
|
|
|
|
"github.com/manyakrus/starter/stopapp"
|
2023-03-17 11:20:09 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestConnect_err(t *testing.T) {
|
|
|
|
|
//ProgramDir := micro.ProgramDir_Common()
|
|
|
|
|
config.LoadEnv()
|
|
|
|
|
err := Connect_err()
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Error("nats_connect.TestConnect_err() error: ", err)
|
|
|
|
|
}
|
|
|
|
|
CloseConnection()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCloseConnection(t *testing.T) {
|
|
|
|
|
//ProgramDir := micro.ProgramDir_Common()
|
|
|
|
|
config.LoadEnv()
|
|
|
|
|
Connect()
|
|
|
|
|
CloseConnection()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestStartNats(t *testing.T) {
|
|
|
|
|
//ProgramDir := micro.ProgramDir_Common()
|
|
|
|
|
config.LoadEnv()
|
|
|
|
|
StartNats()
|
|
|
|
|
micro.Pause(20)
|
|
|
|
|
|
|
|
|
|
_ = contextmain.GetContext()
|
|
|
|
|
contextmain.CancelContext()
|
|
|
|
|
|
|
|
|
|
stopapp.GetWaitGroup_Main().Wait()
|
|
|
|
|
|
|
|
|
|
contextmain.GetNewContext()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestWaitStop(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
stopapp.GetWaitGroup_Main().Add(1)
|
|
|
|
|
go WaitStop()
|
|
|
|
|
|
|
|
|
|
_ = contextmain.GetContext()
|
|
|
|
|
contextmain.CancelContext()
|
|
|
|
|
|
|
|
|
|
stopapp.GetWaitGroup_Main().Wait()
|
|
|
|
|
|
|
|
|
|
contextmain.GetNewContext()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestConnect(t *testing.T) {
|
|
|
|
|
//ProgramDir := micro.ProgramDir_Common()
|
|
|
|
|
config.LoadEnv()
|
|
|
|
|
Connect()
|
|
|
|
|
CloseConnection()
|
|
|
|
|
}
|