-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider_test.go
More file actions
63 lines (55 loc) · 1.62 KB
/
provider_test.go
File metadata and controls
63 lines (55 loc) · 1.62 KB
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
55
56
57
58
59
60
61
62
63
package edgeone
import (
"context"
"fmt"
"os"
"testing"
"time"
"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")
)
func TestAppendRecords(t *testing.T) {
recs, err := provider.AppendRecords(context.Background(), zone, []libdns.Record{
libdns.RR{Name: "one", TTL: 10 * time.Minute, Type: "A", Data: "1.1.1.1"},
})
if err != nil {
t.Fatalf("AppendRecords: %v", err)
}
fmt.Println("AppendRecords:", recs)
}
func TestSetRecords(t *testing.T) {
recs, err := provider.SetRecords(context.Background(), zone, []libdns.Record{
libdns.RR{Name: "one", TTL: 10 * time.Minute, Type: "A", Data: "1.1.1.2"},
libdns.TXT{Name: "one3", TTL: 10 * time.Minute, Text: "hello world"},
})
if err != nil {
t.Fatalf("SetRecords: %v", err)
}
fmt.Println("SetRecords:", recs)
}
func TestGetRecords(t *testing.T) {
recs, err := provider.GetRecords(context.Background(), zone)
if err != nil {
t.Fatalf("GetRecords: %v", err)
}
fmt.Println("GetRecords:", recs)
}
func TestDeleteRecords(t *testing.T) {
recs, err := provider.DeleteRecords(context.Background(), zone, []libdns.Record{
libdns.RR{Name: "two", TTL: 10 * time.Minute, Type: "AAAA", Data: "2606:4700:4700::1111"},
libdns.RR{Name: "one", TTL: 10 * time.Minute, Type: "TXT", Data: "hello world2"},
libdns.RR{Name: "one", TTL: 10 * time.Second, Type: "A"},
libdns.TXT{Name: "one3", TTL: 10 * time.Minute, Text: "hello world"},
libdns.TXT{Name: "_acme-challenge"},
})
if err != nil {
t.Fatalf("DeleteRecords: %v", err)
}
fmt.Println("DeleteRecords:", recs)
}