MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestBatch

Function TestBatch

backend/plugin/parser/tsql/batch/batch_test.go:58–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func 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
96func getBatchResults(a *require.Assertions, input string) []batchResult {
97 batch := NewBatcher(input)

Callers

nothing calls this directly

Calls 5

RecordFunction · 0.92
getBatchResultsFunction · 0.85
UnmarshalMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected