mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: rename ExpectMatchContext to ExpectMatch (#25998)
Cleans the last few instances of ExpectMatch that didn't use the new `(ctx, ...)` variant, then deletes the deprecated method and renames `ExpectMatchContext` to drop the `Context` suffix.
This commit is contained in:
@@ -145,31 +145,11 @@ func (e *Expecter) logClose(name string, c io.Closer) {
|
||||
e.Logf("closed %s: %v", name, err)
|
||||
}
|
||||
|
||||
// Deprecated: use ExpectMatchContext instead.
|
||||
// This uses a background context, so will not respect the test's context.
|
||||
func (e *Expecter) ExpectMatch(str string) string {
|
||||
return e.expectMatchContextFunc(str, e.ExpectMatchContext)
|
||||
}
|
||||
|
||||
func (e *Expecter) ExpectRegexMatch(str string) string {
|
||||
return e.expectMatchContextFunc(str, e.ExpectRegexMatchContext)
|
||||
}
|
||||
|
||||
func (e *Expecter) expectMatchContextFunc(str string, fn func(ctx context.Context, str string) string) string {
|
||||
e.t.Helper()
|
||||
|
||||
timeout, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
|
||||
defer cancel()
|
||||
|
||||
return fn(timeout, str)
|
||||
}
|
||||
|
||||
// TODO(mafredri): Rename this to ExpectMatch when refactoring.
|
||||
func (e *Expecter) ExpectMatchContext(ctx context.Context, str string) string {
|
||||
func (e *Expecter) ExpectMatch(ctx context.Context, str string) string {
|
||||
return e.expectMatcherFunc(ctx, str, strings.Contains)
|
||||
}
|
||||
|
||||
func (e *Expecter) ExpectRegexMatchContext(ctx context.Context, str string) string {
|
||||
func (e *Expecter) ExpectRegexMatch(ctx context.Context, str string) string {
|
||||
return e.expectMatcherFunc(ctx, str, func(src, pattern string) bool {
|
||||
return regexp.MustCompile(pattern).MatchString(src)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user