-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.go
54 lines (49 loc) · 1.08 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package sms
import (
"flag"
"log"
"testing"
)
var err error
var client *Client
var ak, sk, sn, tc string
func init() {
flag.StringVar(&ak, "access_key", "", "您的ACCESS KEY")
flag.StringVar(&sk, "secret_key", "", "您的SECRET KEY")
flag.StringVar(&sn, "sign_name", "", "您的短信发送签名")
flag.StringVar(&tc, "template_code", "", "您的短信发送模板")
flag.Parse()
client, err = New(ak, sk, SignName(sn), Template(tc))
if err != nil {
log.Fatalln(err)
}
}
func TestClient_Send(t *testing.T) {
err = client.Send(
Mobile("17757171482"),
Parameter(map[string]string{"code": "123456"}),
)
if err != nil {
t.Error(err)
}
}
func TestClient_SendBatch(t *testing.T) {
items := []BatchItem{
{
// "您的短信签名, 若已全局配置则可留空"
Sign: "",
Mobile: "17757171482",
Params: map[string]string{"code": "01234"},
},
{
// "您的短信签名, 若已全局配置则可留空"
Sign: "",
Mobile: "17757171483",
Params: map[string]string{"code": "56789"},
},
}
err = client.SendBatch(items)
if err != nil {
t.Error(err)
}
}