-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodule_test.go
44 lines (38 loc) · 1.13 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 huaweicloud
import (
"fmt"
"testing"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
"github.com/libdns/huaweicloud"
)
func TestUnmarshalCaddyFile(t *testing.T) {
tests := []string{
`huaweicloud {
access_key_id thekey
secret_access_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{&huaweicloud.Provider{}}
// when
err := p.UnmarshalCaddyfile(dispenser)
// then
if err != nil {
t.Errorf("UnmarshalCaddyfile failed with %v", err)
return
}
expectedAccessKeyId := "thekey"
actualAccessKeyId := p.Provider.AccessKeyId
if expectedAccessKeyId != actualAccessKeyId {
t.Errorf("Expected AccessKeyId to be '%s' but got '%s'", expectedAccessKeyId, actualAccessKeyId)
}
expectedSecretAccessKey := "itsasecret"
actualSecretAccessKey := p.Provider.SecretAccessKey
if expectedSecretAccessKey != actualSecretAccessKey {
t.Errorf("Expected SecretAccessKey to be '%s' but got '%s'", expectedSecretAccessKey, actualSecretAccessKey)
}
})
}
}