-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
57 lines (50 loc) · 1.2 KB
/
Copy pathclient_test.go
File metadata and controls
57 lines (50 loc) · 1.2 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
package regfishapi
import (
"log"
"os"
"testing"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert"
)
func TestNewClient(t *testing.T) {
err := godotenv.Load(os.ExpandEnv(".env"))
if err != nil {
log.Fatalf("Error getting env %v\n", err)
}
apiToken := os.Getenv("RF_API_KEY")
client := NewClient(apiToken)
assert.NotNil(t, client)
assert.Equal(t, "https://api.regfish.de", client.BaseURL)
t.Run("Testing DNS records", func(t *testing.T) {
t.Run("Create a new record", func(t *testing.T) {
// Create a new record
record := Record{
Name: "go-client-test1.example.com.",
Type: "A",
Data: "10.2.3.4",
TTL: 60,
}
_, err := client.CreateRecord(record)
assert.Nil(t, err)
})
RecordID := 0
t.Run("Update an existing record", func(t *testing.T) {
// Update an existing record
record := Record{
ID: 1,
Name: "go-client-test1.example.com.",
Type: "A",
Data: "10.2.3.5",
TTL: 61,
}
res, err := client.UpdateRecord(record)
RecordID = res.ID
assert.Nil(t, err)
})
t.Run("Delete an existing record", func(t *testing.T) {
// Delete an existing record
err := client.DeleteRecord(RecordID)
assert.Nil(t, err)
})
})
}