1
0
mirror of https://github.com/ManyakRus/starter.git synced 2024-11-21 18:16:31 +02:00

сделал tinkoff_connect.go

This commit is contained in:
Nikitin Aleksandr 2024-11-19 12:43:10 +03:00
parent 4e128cc5f8
commit 75b0af4a4d
4 changed files with 22 additions and 9 deletions

View File

@ -71,7 +71,7 @@ TELEGRAM_API_KEY=""
TELEGRAM_CHAT_ID_TEST=
#Tinkoff invest API
INVEST_HOST=
INVEST_PORT=
INVEST_HOST=sandbox-invest-public-api.tinkoff.ru
INVEST_PORT=443
INVEST_TOKEN=
INVEST_ACCOUNTID=

View File

@ -37,7 +37,7 @@ func TestSendMessage(t *testing.T) {
CreateTelegramClient(nil)
err = Connect_err()
err = Connect_err(nil)
if err != nil {
t.Error("telegramclient_test.TestSendMessage() error: ", err)
return
@ -89,7 +89,7 @@ func TestConnectTelegram(t *testing.T) {
CreateTelegramClient(nil)
err := Connect_err()
err := Connect_err(nil)
if err != nil {
t.Error("telegramclient_test.TestConnectTelegram() error: ", err)
}
@ -114,7 +114,7 @@ func TestSendMessage_Many(t *testing.T) {
CreateTelegramClient(nil)
err := Connect_err()
err := Connect_err(nil)
if err != nil {
t.Error("telegramclient_test.TestSendMessage() Connect() error: ", err)
}

View File

@ -25,7 +25,7 @@ type SettingsINI struct {
var Settings SettingsINI
// Conn - подключение к серверу GRPC
var Conn *investgo.Client
var Client *investgo.Client
// mutex_Connect - защита от многопоточности Reconnect()
var mutex_Connect = &sync.Mutex{}
@ -70,8 +70,8 @@ func Connect_err() error {
ctx := contextmain.GetContext()
//addr := Settings.Host + ":" + Settings.Port
Config := investgo.Config{}
Conn, err = investgo.NewClient(ctx, Config, log.GetLog())
Config := Settings.Config
Client, err = investgo.NewClient(ctx, Config, log.GetLog())
if err != nil {
return err
}
@ -184,7 +184,7 @@ func CloseConnection() {
// CloseConnection - закрывает подключение к GRPC, и возвращает ошибку
func CloseConnection_err() error {
err := Conn.Stop()
err := Client.Stop()
return err
}

View File

@ -12,3 +12,16 @@ func TestFillSettings(t *testing.T) {
t.Error("FillSettings() error: ", err)
}
}
func TestConnect_err(t *testing.T) {
config_main.LoadEnv()
err := Connect_err()
if err != nil {
t.Error("TestConnect error: ", err)
}
err = CloseConnection_err()
if err != nil {
t.Error("TestConnect() error: ", err)
}
}