in progress
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
key.test
|
||||||
1
sms.go
1
sms.go
@@ -8,6 +8,7 @@ type RequestSMS struct {
|
|||||||
ApiKey string `json:"apikey"`
|
ApiKey string `json:"apikey"`
|
||||||
Phone string `json:"phones"`
|
Phone string `json:"phones"`
|
||||||
Message string `json:"mes"`
|
Message string `json:"mes"`
|
||||||
|
Sender string `json:"sender,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResponseSMS struct {
|
type ResponseSMS struct {
|
||||||
|
|||||||
27
sms_test.go
27
sms_test.go
@@ -4,6 +4,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -11,12 +13,33 @@ func generateCode() string {
|
|||||||
return fmt.Sprintf("%04d", rand.Intn(10000))
|
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) {
|
func TestSendSMS(t *testing.T) {
|
||||||
|
// Загружаем API-ключ из файла
|
||||||
|
apiKey := loadAPIKey(t)
|
||||||
|
|
||||||
// Создаем тестовый запрос
|
// Создаем тестовый запрос
|
||||||
req := RequestSMS{
|
req := RequestSMS{
|
||||||
ApiKey: "80g8w5-t4D5n2X5v2!8s1S3p5E2n2X68e", // Замените на реальный API-ключ для теста
|
ApiKey: apiKey,
|
||||||
Phone: "79397804368", // Замените на реальный номер телефона
|
Phone: "79857770038", // Замените на реальный номер телефона
|
||||||
Message: "Код подтверждения: " + generateCode(),
|
Message: "Код подтверждения: " + generateCode(),
|
||||||
|
Sender: "Noglik-Market",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Вызываем тестируемую функцию
|
// Вызываем тестируемую функцию
|
||||||
|
|||||||
Reference in New Issue
Block a user