-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache_test.go
53 lines (48 loc) · 1.25 KB
/
cache_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
52
53
package certmaker
import (
"path/filepath"
"testing"
)
func TestNewCache(t *testing.T) {
c, err := NewCache()
if err != nil {
t.Fatalf("expeced no error with NewCache(), got %s", err.Error())
}
if filepath.Base(c.CacheDir) != ".certs" {
t.Fatalf("expected CacheDir .certs, got %s", c.CacheDir)
}
if c.PrivateKeyFilename != "key.pem" {
t.Fatalf("expected private key filename key.pem, got %s", c.PrivateKeyFilename)
}
if c.CertificateFilename != "cert.pem" {
t.Fatalf("expected certificate filename cert.pem, got %s", c.CertificateFilename)
}
}
func TestCache_GetCertificatePath(t *testing.T) {
type fields struct {
CacheDir string
PrivateKeyFilename string
CertificateFilename string
}
tests := []struct {
name string
fields fields
want string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Cache{
PrivateKeyFilename: tt.fields.PrivateKeyFilename,
CertificateFilename: tt.fields.CertificateFilename,
}
if err := c.SetDir(tt.fields.CacheDir); err != nil {
t.Fatalf("expected no error; got %s", err.Error())
}
if got := c.GetCertificatePath(); got != tt.want {
t.Errorf("GetCertificatePath() = %v, want %v", got, tt.want)
}
})
}
}