(t *testing.T, file string, record bool)
| 23 | } |
| 24 | |
| 25 | func runLimitTest(t *testing.T, file string, record bool) { |
| 26 | var testCases []limitTestData |
| 27 | filepath := filepath.Join("test-data", file) |
| 28 | yamlFile, err := os.Open(filepath) |
| 29 | require.NoError(t, err) |
| 30 | defer yamlFile.Close() |
| 31 | |
| 32 | byteValue, err := io.ReadAll(yamlFile) |
| 33 | require.NoError(t, err) |
| 34 | err = yaml.Unmarshal(byteValue, &testCases) |
| 35 | require.NoError(t, err) |
| 36 | |
| 37 | for i, tc := range testCases { |
| 38 | want := getStatementWithResultLimit(tc.Stmt, tc.Limit) |
| 39 | if record { |
| 40 | testCases[i].Want = want |
| 41 | } else { |
| 42 | require.Equal(t, tc.Want, want, tc.Stmt) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if record { |
| 47 | err := yamlFile.Close() |
| 48 | require.NoError(t, err) |
| 49 | yamltest.Record(t, filepath, testCases) |
| 50 | } |
| 51 | } |
no test coverage detected