-
Notifications
You must be signed in to change notification settings - Fork 28
/
config_test.go
51 lines (44 loc) · 1.06 KB
/
config_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
package powerdns
import (
"context"
"net/http"
"testing"
"github.com/jarcoal/httpmock"
)
func registerConfigsMockResponder() {
httpmock.RegisterResponder("GET", generateTestAPIVHostURL()+"/config",
func(req *http.Request) (*http.Response, error) {
if res := verifyAPIKey(req); res != nil {
return res, nil
}
configMock := []ConfigSetting{
{
Name: String("signing-threads"),
Type: String("ConfigSetting"),
Value: String("3"),
},
}
return httpmock.NewJsonResponse(http.StatusOK, configMock)
},
)
}
func TestListConfig(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
registerConfigsMockResponder()
p := initialisePowerDNSTestClient()
config, err := p.Config.List(context.Background())
if err != nil {
t.Errorf("%s", err)
}
if len(config) == 0 {
t.Error("Received amount of config settings is 0")
}
}
func TestListConfigError(t *testing.T) {
p := initialisePowerDNSTestClient()
p.Port = "x"
if _, err := p.Config.List(context.Background()); err == nil {
t.Error("error is nil")
}
}