6
0
gaore-common-sdk-go/services/ip/client_test.go
liguanjie eea0eb790e 【ip服务】
1、新增查询单个、多个ip地区信息
2025-06-24 11:55:49 +08:00

49 lines
870 B
Go

package ip
import (
"fmt"
"testing"
)
// 测试获取单个ip地区信息
func TestGetIp(t *testing.T) {
client, newErr := NewClient()
if newErr != nil {
panic(newErr)
}
req := CreateIpRequest(IpParam{
Ip: "114.234.202.136",
})
res, doErr := client.CreateGetIpRequest(req)
if doErr != nil {
panic(doErr)
}
if res.Code != 0 {
t.Error("查询多个ip失败")
}
fmt.Printf(fmt.Sprintf("%v", res))
}
// 测试获取多个ip地区信息
func TestGetIps(t *testing.T) {
client, newErr := NewClient()
if newErr != nil {
panic(newErr)
}
req := CreateIpsRequest(IpsParam{
Ips: []string{
"2001:ee0:5208:e600:4c51:3189:28a4:b668",
"114.234.202.136",
},
})
res, err := client.CreateGetIpsRequest(req)
if err != nil {
t.Error(err)
return
}
if res.Code != 0 {
t.Error("查询多个ip失败")
}
fmt.Printf(fmt.Sprintf("%v", res))
}