MCPcopy Index your code
hub / github.com/coder/coder / expectMatcherFunc

Method expectMatcherFunc

testutil/expecter/expecter.go:158–183  ·  view source on GitHub ↗
(ctx context.Context, str string, fn func(src, pattern string) bool)

Source from the content-addressed store, hash-verified

156}
157
158func (e *Expecter) expectMatcherFunc(ctx context.Context, str string, fn func(src, pattern string) bool) string {
159 e.t.Helper()
160
161 var buffer bytes.Buffer
162 err := e.doMatchWithDeadline(ctx, "ExpectMatchContext", func(rd *bufio.Reader) error {
163 for {
164 r, _, err := rd.ReadRune()
165 if err != nil {
166 return err
167 }
168 _, err = buffer.WriteRune(r)
169 if err != nil {
170 return err
171 }
172 if fn(buffer.String(), str) {
173 return nil
174 }
175 }
176 })
177 if err != nil {
178 e.fatalf("read error", "%v (wanted %q; got %q)", err, str, buffer.String())
179 return ""
180 }
181 e.Logf("matched %q = %q", str, buffer.String())
182 return buffer.String()
183}
184
185// ExpectNoMatchBefore validates that `match` does not occur before `before`.
186func (e *Expecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string {

Callers 2

ExpectMatchMethod · 0.95
ExpectRegexMatchMethod · 0.95

Calls 6

doMatchWithDeadlineMethod · 0.95
fatalfMethod · 0.95
LogfMethod · 0.95
HelperMethod · 0.65
ReadRuneMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected