-
Notifications
You must be signed in to change notification settings - Fork 7
/
module_test.go
44 lines (38 loc) · 1.05 KB
/
module_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
package porkbun
import (
"fmt"
"testing"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
porkbun "github.com/libdns/porkbun"
)
func TestUnmarshalCaddyFile(t *testing.T) {
tests := []string{
`porkbun {
api_key thekey
api_secret_key itsasecret
}`}
for i, tc := range tests {
t.Run(fmt.Sprintf("test case %d", i), func(t *testing.T) {
// given
dispenser := caddyfile.NewTestDispenser(tc)
p := Provider{&porkbun.Provider{}}
// when
err := p.UnmarshalCaddyfile(dispenser)
// then
if err != nil {
t.Errorf("UnmarshalCaddyfile failed with %v", err)
return
}
expectedAPIKey := "thekey"
actualAPIKey := p.Provider.APIKey
if expectedAPIKey != actualAPIKey {
t.Errorf("Expected APIKey to be '%s' but got '%s'", expectedAPIKey, actualAPIKey)
}
expectedAPISecretKey := "itsasecret"
actualApiSecretKey := p.Provider.APISecretKey
if expectedAPISecretKey != actualApiSecretKey {
t.Errorf("Expected ApiSecretKey to be '%s' but got '%s'", expectedAPISecretKey, actualApiSecretKey)
}
})
}
}