(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestBatch(t *testing.T) { |
| 59 | type TestCase struct { |
| 60 | // input is the input string. |
| 61 | // The input string can be a single SQL statement or a batch of SQL statements. |
| 62 | Input string `yaml:"input"` |
| 63 | Description string `yaml:"description"` |
| 64 | Batches []batchResult `yaml:"batches"` |
| 65 | } |
| 66 | |
| 67 | a := require.New(t) |
| 68 | |
| 69 | filePath := "testdata/test_batch.yaml" |
| 70 | f, err := os.Open(filePath) |
| 71 | a.NoError(err) |
| 72 | defer f.Close() |
| 73 | |
| 74 | bytes, err := io.ReadAll(f) |
| 75 | a.NoError(err) |
| 76 | |
| 77 | var testCases []TestCase |
| 78 | a.NoError(yaml.Unmarshal(bytes, &testCases)) |
| 79 | |
| 80 | const ( |
| 81 | record = false |
| 82 | ) |
| 83 | for i, tc := range testCases { |
| 84 | batchResults := getBatchResults(a, tc.Input) |
| 85 | if record { |
| 86 | testCases[i].Batches = batchResults |
| 87 | } else { |
| 88 | a.Equalf(tc.Batches, batchResults, "Input: %s", tc.Input) |
| 89 | } |
| 90 | } |
| 91 | if record { |
| 92 | yamltest.Record(t, filePath, testCases) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func getBatchResults(a *require.Assertions, input string) []batchResult { |
| 97 | batch := NewBatcher(input) |
nothing calls this directly
no test coverage detected