in progress

This commit is contained in:
2026-02-03 21:42:44 +03:00
parent 69ec3a6050
commit 0238174f3d
3 changed files with 27 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
key.test

1
sms.go
View File

@@ -8,6 +8,7 @@ type RequestSMS struct {
ApiKey string `json:"apikey"`
Phone string `json:"phones"`
Message string `json:"mes"`
Sender string `json:"sender,omitempty"`
}
type ResponseSMS struct {

View File

@@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"math/rand"
"os"
"path/filepath"
"testing"
)
@@ -11,12 +13,33 @@ func generateCode() string {
return fmt.Sprintf("%04d", rand.Intn(10000))
}
func loadAPIKey(t *testing.T) string {
dirPath, err := os.Getwd()
if err != nil {
t.Fatalf("Не удалось получить текущий каталог: %v", err)
}
data, err := os.ReadFile(filepath.Join(dirPath, "key.test"))
if err != nil {
t.Fatalf("Не удалось прочитать файл key.test: %v", err)
}
return string(data)
}
func TestLoadAPIKey(t *testing.T) {
key := loadAPIKey(t)
t.Log(key)
}
func TestSendSMS(t *testing.T) {
// Загружаем API-ключ из файла
apiKey := loadAPIKey(t)
// Создаем тестовый запрос
req := RequestSMS{
ApiKey: "80g8w5-t4D5n2X5v2!8s1S3p5E2n2X68e", // Замените на реальный API-ключ для теста
Phone: "79397804368", // Замените на реальный номер телефона
ApiKey: apiKey,
Phone: "79857770038", // Замените на реальный номер телефона
Message: "Код подтверждения: " + generateCode(),
Sender: "Noglik-Market",
}
// Вызываем тестируемую функцию