vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletmanager/vreplication/queryhistory/expectation.go (about) 1 package queryhistory 2 3 import "fmt" 4 5 // Expectation represents an expectation about the contents of a query. 6 type Expectation interface { 7 ExpectQuery(string) 8 MatchQuery(string) (bool, error) 9 Query() string 10 String() string 11 } 12 13 type expectation struct { 14 query string 15 } 16 17 func newExpectation(query string) Expectation { 18 return &expectation{query} 19 } 20 21 func (e *expectation) ExpectQuery(query string) { 22 e.query = query 23 } 24 25 func (e *expectation) MatchQuery(query string) (bool, error) { 26 return MatchQueries(e.query, query) 27 } 28 29 func (e *expectation) Query() string { 30 return e.query 31 } 32 33 func (e *expectation) String() string { 34 if e == nil { 35 return "<nil>" 36 } 37 38 return fmt.Sprintf("query=%s", e.query) 39 }