This repository was archived by the owner on Jul 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors_test.go
More file actions
57 lines (50 loc) · 1.35 KB
/
errors_test.go
File metadata and controls
57 lines (50 loc) · 1.35 KB
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
package secureio
import (
"errors"
"fmt"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
xerrors "github.com/xaionaro-go/errors"
)
func TestErrTypes(t *testing.T) {
m := map[reflect.Type]struct{}{}
for _, err := range []error{
newErrCannotDecrypt(),
newErrPartialWrite(),
newErrInvalidSignature(),
newErrWrongKeyLength(0, 0),
newErrCannotLoadKeys(errors.New("unit-test")),
newErrAlreadyClosed(),
newErrKeyExchangeTimeout(),
newErrTooShort(0, 0),
newErrUnencrypted(),
newErrInvalidChecksum(nil, nil),
newErrPayloadTooBig(0, 0),
newErrMonopolized(),
newErrNotMonopolized(),
newErrCanceled(),
newErrAnswersModeMismatch(0, 0),
newErrCannotSetReadDeadline(nil),
newErrCannotPauseOrUnpauseFromThisState(),
newErrLocalPrivateKeyIsNil(),
newErrRemotePublicKeyIsNil(),
newErrRemoteKeyHasNotChanged(),
newErrInvalidPublicKey(),
newErrNegotiationTimeout("unit-test"),
newErrNegotiationCancelled("unit-test"),
newErrAlreadyStarted(),
newErrUnknownSubType(-1),
} {
_ = err.Error() // check if there's no panic
xerr, ok := err.(*xerrors.Error)
if !assert.True(t, ok, fmt.Sprintf("%T", err)) {
continue
}
typ := reflect.TypeOf(xerr.Deepest().Err)
_, alreadyExists := m[typ]
assert.False(t, alreadyExists, fmt.Sprintf("%T:%v", err, typ))
m[typ] = struct{}{}
}
assert.Nil(t, newErrCannotLoadKeys(nil))
}