Skip to content

Commit 5104ed7

Browse files
committed
Added documentation for containsSQLOutput
Signed-off-by: Lou Marvin Caraig <[email protected]>
1 parent 6a16536 commit 5104ed7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cmd/srcd/cmd/sql_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,27 @@ func (s *SQLREPLTestSuite) waitMysqlCliContainerStopped(retries int, retryTimeou
204204
return fmt.Errorf("maximum number of retries (%d) reached while waiting to stop container", retries)
205205
}
206206

207+
// containsSQLOutput returns `true` if the given string is a SQL output table.
208+
// To detect whether the `out` is a SQL output table, this checks that there
209+
// are exactly 3 separators matching this regex ``\+-+\+`.
210+
// In fact an example of SQL output is the following:
211+
//
212+
// +--------------+ <-- first separator
213+
// | Table |
214+
// +--------------+ <-- second separator
215+
// | blobs |
216+
// | commit_blobs |
217+
// | commit_files |
218+
// | commit_trees |
219+
// | commits |
220+
// | files |
221+
// | ref_commits |
222+
// | refs |
223+
// | remotes |
224+
// | repositories |
225+
// | tree_entries |
226+
// +--------------+ <-- third separator
227+
//
207228
func (s *SQLREPLTestSuite) containsSQLOutput(out string) bool {
208229
sep := regexp.MustCompile(`\+-+\+`)
209230
matches := sep.FindAllStringIndex(out, -1)

0 commit comments

Comments
 (0)