forked from caddy-dns/netcup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
netcup_test.go
51 lines (44 loc) · 1.32 KB
/
netcup_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 netcup
import (
"fmt"
"testing"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
"github.com/libdns/netcup"
)
func TestUnmarshalCaddyFileExtractsApiToken(t *testing.T) {
tests := []string{
`netcup {
customer_number 12345
api_key apikey
api_password pw123
}`}
for i, tc := range tests {
t.Run(fmt.Sprintf("test case %d", i), func(t *testing.T) {
// given
dispenser := caddyfile.NewTestDispenser(tc)
p := Provider{&netcup.Provider{}}
// when
err := p.UnmarshalCaddyfile(dispenser)
// then
if err != nil {
t.Errorf("UnmarshalCaddyfile failed with %v", err)
return
}
expectedCustomerNumber := "12345"
actualCustomerNumber := p.Provider.CustomerNumber
if expectedCustomerNumber != actualCustomerNumber {
t.Errorf("Expected CustomerNumber to be '%s' but got '%s'", expectedCustomerNumber, actualCustomerNumber)
}
expectedAPIKey := "apikey"
actualAPIKey := p.Provider.APIKey
if expectedAPIKey != actualAPIKey {
t.Errorf("Expected CustomerNumber to be '%s' but got '%s'", expectedAPIKey, actualAPIKey)
}
expectedAPIPassword := "pw123"
actualAPIPassword := p.Provider.APIPassword
if expectedAPIPassword != actualAPIPassword {
t.Errorf("Expected CustomerNumber to be '%s' but got '%s'", expectedAPIPassword, actualAPIPassword)
}
})
}
}