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

Method ExpectNoMatchBefore

testutil/expecter/expecter.go:186–216  ·  view source on GitHub ↗

ExpectNoMatchBefore validates that `match` does not occur before `before`.

(ctx context.Context, match, before string)

Source from the content-addressed store, hash-verified

184
185// ExpectNoMatchBefore validates that `match` does not occur before `before`.
186func (e *Expecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string {
187 e.t.Helper()
188
189 var buffer bytes.Buffer
190 err := e.doMatchWithDeadline(ctx, "ExpectNoMatchBefore", func(rd *bufio.Reader) error {
191 for {
192 r, _, err := rd.ReadRune()
193 if err != nil {
194 return err
195 }
196 _, err = buffer.WriteRune(r)
197 if err != nil {
198 return err
199 }
200
201 if strings.Contains(buffer.String(), match) {
202 return xerrors.Errorf("found %q before %q", match, before)
203 }
204
205 if strings.Contains(buffer.String(), before) {
206 return nil
207 }
208 }
209 })
210 if err != nil {
211 e.fatalf("read error", "%v (wanted no %q before %q; got %q)", err, match, before, buffer.String())
212 return ""
213 }
214 e.Logf("matched %q = %q", before, stripansi.Strip(buffer.String()))
215 return buffer.String()
216}
217
218func (e *Expecter) Peek(ctx context.Context, n int) []byte {
219 e.t.Helper()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected