forked from libdns/tencentcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider_test.go
More file actions
49 lines (43 loc) · 922 Bytes
/
provider_test.go
File metadata and controls
49 lines (43 loc) · 922 Bytes
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
package tencentcloud
import (
"context"
"net/netip"
"os"
"testing"
"github.com/libdns/libdns"
)
var provider = &Provider{
SecretId: os.Getenv("TC_SECRET_ID"),
SecretKey: os.Getenv("TC_SECRET_KEY"),
}
var (
zone = os.Getenv("TC_ZONE")
name = os.Getenv("TC_NAME")
value = os.Getenv("TC_VALUE")
)
func TestSetRecords(t *testing.T) {
netip, err := netip.ParseAddr(value)
if err != nil {
t.Fatalf("parse error: %v", err)
}
_, err = provider.SetRecords(context.Background(), zone, []libdns.Record{
libdns.Address{
Name: name,
IP: netip,
},
})
if err != nil {
t.Fatalf("SetRecords: %v", err)
}
}
func TestGetRecords(t *testing.T) {
records, err := provider.GetRecords(context.Background(), zone)
if err != nil {
t.Fatalf("GetRecords: %v", err)
}
for _, record := range records {
rr := record.RR()
t.Logf("RecordType: %s, Name: %s, Data: %s",
rr.Type, rr.Name, rr.Data)
}
}