-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
98 lines (85 loc) · 1.66 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package simplyComClient
import (
"fmt"
"testing"
)
// Plot in your own api details for testing.
var fixture = CreateSimplyClient("", "")
type testData struct {
domain string
data string
data2 string
bogusIP string
}
func TestAll(t *testing.T) {
data := testData{
domain: "test2.ddns.example.dk",
data: "test_txt_data",
data2: "test_txt_data_2",
bogusIP: "19.19.19.20",
}
testAdd(t, data)
id := testGet(t, data)
testUpdate(t, data, id)
testRemove(t, data, id)
testddns(t, data)
testddnsWithoutIp(t, data)
}
func testAdd(t *testing.T, data testData) {
id, err := fixture.AddRecord(data.domain, data.data, "TXT")
if err != nil {
t.Fail()
}
if id == 0 {
t.Fail()
}
fmt.Println(id)
}
func testUpdate(t *testing.T, data testData, id int) {
res, err := fixture.UpdateRecord(id, data.domain, data.data2, "TXT")
if err != nil {
t.Fail()
}
if res != true {
t.Fail()
}
fmt.Println(id)
}
func testRemove(t *testing.T, data testData, id int) {
res2, _, _ := fixture.GetRecord(data.domain, data.data2, "TXT")
if res2 != id {
t.Fail()
}
res := fixture.RemoveRecord(id, data.domain)
if res != true {
t.Fail()
}
}
func testGet(t *testing.T, data testData) int {
id, recData, _ := fixture.GetRecord(data.domain, "", "TXT")
if id == 0 {
t.Fail()
}
if recData == "" {
t.Fail()
}
return id
}
func testddns(t *testing.T, data testData) {
res, err := fixture.UpdateDDNS(data.domain, data.bogusIP)
if err != nil {
t.Fail()
}
if res != true {
t.Fail()
}
}
func testddnsWithoutIp(t *testing.T, data testData) {
res, err := fixture.UpdateDDNS(data.domain, "")
if err != nil {
t.Fail()
}
if res != true {
t.Fail()
}
}