-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrw_callback_test.go
39 lines (36 loc) · 944 Bytes
/
rw_callback_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
package acmewrapper
import (
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestSaveLoadCallback(t *testing.T) {
memFS := map[string][]byte{}
_, err := New(Config{
Server: TESTAPI,
TOSCallback: TOSAgree,
Domains: TESTDOMAINS,
PrivateKeyFile: "testinguser.key",
RegistrationFile: "testinguser.reg",
Address: TLSADDRESS,
TLSCertFile: "cert.crt",
TLSKeyFile: "key.pem",
SaveFileCallback: func(path string, contents []byte) error {
memFS[path] = contents
return nil
},
LoadFileCallback: func(path string) ([]byte, error) {
contents, ok := memFS[path]
if !ok {
return nil, os.ErrNotExist
}
return contents, nil
},
})
require.NoError(t, err)
require.Len(t, memFS, 4)
require.NotNil(t, memFS["testinguser.key"])
require.NotNil(t, memFS["testinguser.reg"])
require.NotNil(t, memFS["cert.crt"])
require.NotNil(t, memFS["key.pem"])
}