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

Method ExpectNoMatchBefore

pty/ptytest/ptytest.go:211–241  ·  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

209
210// ExpectNoMatchBefore validates that `match` does not occur before `before`.
211func (e *outExpecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string {
212 e.t.Helper()
213
214 var buffer bytes.Buffer
215 err := e.doMatchWithDeadline(ctx, "ExpectNoMatchBefore", func(rd *bufio.Reader) error {
216 for {
217 r, _, err := rd.ReadRune()
218 if err != nil {
219 return err
220 }
221 _, err = buffer.WriteRune(r)
222 if err != nil {
223 return err
224 }
225
226 if strings.Contains(buffer.String(), match) {
227 return xerrors.Errorf("found %q before %q", match, before)
228 }
229
230 if strings.Contains(buffer.String(), before) {
231 return nil
232 }
233 }
234 })
235 if err != nil {
236 e.fatalf("read error", "%v (wanted no %q before %q; got %q)", err, match, before, buffer.String())
237 return ""
238 }
239 e.logf("matched %q = %q", before, stripansi.Strip(buffer.String()))
240 return buffer.String()
241}
242
243func (e *outExpecter) Peek(ctx context.Context, n int) []byte {
244 e.t.Helper()

Callers 4

TestCliTemplateCreateFunction · 0.45
TestTemplatePushFunction · 0.45

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 4

TestCliTemplateCreateFunction · 0.36
TestTemplatePushFunction · 0.36