-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy patherror_test.go
59 lines (51 loc) · 1.51 KB
/
error_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
54
55
56
57
58
59
package jwkset
import (
"context"
"encoding/json"
"errors"
"testing"
"time"
)
var (
errStorage = errors.New("storage error")
)
type storageError struct{}
func (s storageError) KeyDelete(_ context.Context, _ string) (ok bool, err error) {
return false, errStorage
}
func (s storageError) KeyRead(_ context.Context, _ string) (JWK, error) {
return JWK{}, errStorage
}
func (s storageError) KeyReadAll(_ context.Context) ([]JWK, error) {
return nil, errStorage
}
func (s storageError) KeyWrite(_ context.Context, _ JWK) error {
return errStorage
}
func (s storageError) JSON(_ context.Context) (json.RawMessage, error) {
return nil, errStorage
}
func (s storageError) JSONPublic(_ context.Context) (json.RawMessage, error) {
return nil, errStorage
}
func (s storageError) JSONPrivate(_ context.Context) (json.RawMessage, error) {
return nil, errStorage
}
func (s storageError) JSONWithOptions(_ context.Context, _ JWKMarshalOptions, _ JWKValidateOptions) (json.RawMessage, error) {
return nil, errStorage
}
func (s storageError) Marshal(_ context.Context) (JWKSMarshal, error) {
return JWKSMarshal{}, errStorage
}
func (s storageError) MarshalWithOptions(_ context.Context, _ JWKMarshalOptions, _ JWKValidateOptions) (JWKSMarshal, error) {
return JWKSMarshal{}, errStorage
}
func TestStorageError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
jwks := storageError{}
_, err := jwks.JSONPublic(ctx)
if err == nil {
t.Fatalf("Expected error, but got none.")
}
}