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

Function TestBackup

backend/plugin/parser/tsql/backup_test.go:107–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestBackup(t *testing.T) {
108 tests := []rollbackCase{}
109
110 const (
111 record = false
112 )
113 var (
114 filepath = "test-data/test_backup.yaml"
115 )
116
117 a := require.New(t)
118 yamlFile, err := os.Open(filepath)
119 a.NoError(err)
120
121 byteValue, err := io.ReadAll(yamlFile)
122 a.NoError(yamlFile.Close())
123 a.NoError(err)
124 a.NoError(yaml.Unmarshal(byteValue, &tests))
125
126 for i, t := range tests {
127 result, err := TransformDMLToSelect(context.Background(), base.TransformContext{}, t.Input, "db", "backupDB", "rollback")
128 a.NoError(err)
129 slices.SortFunc(result, func(a, b base.BackupStatement) int {
130 if a.TargetTableName == b.TargetTableName {
131 if a.Statement < b.Statement {
132 return -1
133 }
134 if a.Statement > b.Statement {
135 return 1
136 }
137 return 0
138 }
139 if a.TargetTableName < b.TargetTableName {
140 return -1
141 }
142 if a.TargetTableName > b.TargetTableName {
143 return 1
144 }
145 return 0
146 })
147
148 if record {
149 tests[i].Result = result
150 } else {
151 a.Equal(t.Result, result, t.Input)
152 }
153 }
154 if record {
155 yamltest.Record(t, filepath, tests)
156 }
157}
158
159// TestIdentityColumnHandling validates that our implementation correctly handles IDENTITY columns
160// This test verifies:

Callers

nothing calls this directly

Calls 6

RecordFunction · 0.92
UnmarshalMethod · 0.80
TransformDMLToSelectFunction · 0.70
OpenMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected