@@ -16,9 +16,6 @@ package expect
16
16
17
17
import (
18
18
"bytes"
19
- "errors"
20
- "os"
21
- "regexp"
22
19
"strings"
23
20
"time"
24
21
)
@@ -62,70 +59,6 @@ type Matcher interface {
62
59
Criteria () interface {}
63
60
}
64
61
65
- // callbackMatcher fulfills the Matcher and CallbackMatcher interface to match
66
- // using its embedded matcher and provide a callback function.
67
- type callbackMatcher struct {
68
- f ConsoleCallback
69
- matcher Matcher
70
- }
71
-
72
- func (cm * callbackMatcher ) Match (v interface {}) bool {
73
- return cm .matcher .Match (v )
74
- }
75
-
76
- func (cm * callbackMatcher ) Criteria () interface {} {
77
- return cm .matcher .Criteria ()
78
- }
79
-
80
- func (cm * callbackMatcher ) Callback (buf * bytes.Buffer ) error {
81
- cb , ok := cm .matcher .(CallbackMatcher )
82
- if ok {
83
- err := cb .Callback (buf )
84
- if err != nil {
85
- return err
86
- }
87
- }
88
- err := cm .f (buf )
89
- if err != nil {
90
- return err
91
- }
92
- return nil
93
- }
94
-
95
- // errorMatcher fulfills the Matcher interface to match a specific error.
96
- type errorMatcher struct {
97
- err error
98
- }
99
-
100
- func (em * errorMatcher ) Match (v interface {}) bool {
101
- err , ok := v .(error )
102
- if ! ok {
103
- return false
104
- }
105
- return errors .Is (err , em .err )
106
- }
107
-
108
- func (em * errorMatcher ) Criteria () interface {} {
109
- return em .err
110
- }
111
-
112
- // pathErrorMatcher fulfills the Matcher interface to match a specific os.PathError.
113
- type pathErrorMatcher struct {
114
- pathError os.PathError
115
- }
116
-
117
- func (em * pathErrorMatcher ) Match (v interface {}) bool {
118
- pathError , ok := v .(* os.PathError )
119
- if ! ok {
120
- return false
121
- }
122
- return * pathError == em .pathError
123
- }
124
-
125
- func (em * pathErrorMatcher ) Criteria () interface {} {
126
- return em .pathError
127
- }
128
-
129
62
// stringMatcher fulfills the Matcher interface to match strings against a given
130
63
// bytes.Buffer.
131
64
type stringMatcher struct {
@@ -147,24 +80,6 @@ func (sm *stringMatcher) Criteria() interface{} {
147
80
return sm .str
148
81
}
149
82
150
- // regexpMatcher fulfills the Matcher interface to match Regexp against a given
151
- // bytes.Buffer.
152
- type regexpMatcher struct {
153
- re * regexp.Regexp
154
- }
155
-
156
- func (rm * regexpMatcher ) Match (v interface {}) bool {
157
- buf , ok := v .(* bytes.Buffer )
158
- if ! ok {
159
- return false
160
- }
161
- return rm .re .Match (buf .Bytes ())
162
- }
163
-
164
- func (rm * regexpMatcher ) Criteria () interface {} {
165
- return rm .re
166
- }
167
-
168
83
// allMatcher fulfills the Matcher interface to match a group of ExpectOpt
169
84
// against any value.
170
85
type allMatcher struct {
0 commit comments