| 94 | } |
| 95 | |
| 96 | func getBatchResults(a *require.Assertions, input string) []batchResult { |
| 97 | batch := NewBatcher(input) |
| 98 | var batchResults []batchResult |
| 99 | for { |
| 100 | command, err := batch.Next() |
| 101 | if err != nil { |
| 102 | if err == io.EOF { |
| 103 | if v := batch.Batch(); v != nil && len(v.Text) > 0 { |
| 104 | // If meet the end of file, get the last batch. |
| 105 | batchResults = append(batchResults, batchResult{ |
| 106 | Statements: *v, |
| 107 | }) |
| 108 | } |
| 109 | batch.Reset(nil) |
| 110 | return batchResults |
| 111 | } |
| 112 | a.NoError(err) |
| 113 | } |
| 114 | if command != nil { |
| 115 | batchResults = append(batchResults, batchResult{ |
| 116 | Statements: *batch.Batch(), |
| 117 | Command: command.String(), |
| 118 | }) |
| 119 | batch.Reset(nil) |
| 120 | } |
| 121 | } |
| 122 | } |