MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestBackup

Function TestBackup

backend/plugin/parser/plsql/backup_test.go:22–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestBackup(t *testing.T) {
23 tests := []rollbackCase{}
24
25 const (
26 record = false
27 )
28 var (
29 filepath = "test-data/test_backup.yaml"
30 )
31
32 a := require.New(t)
33 yamlFile, err := os.Open(filepath)
34 a.NoError(err)
35
36 byteValue, err := io.ReadAll(yamlFile)
37 a.NoError(yamlFile.Close())
38 a.NoError(err)
39 a.NoError(yaml.Unmarshal(byteValue, &tests))
40
41 for i, t := range tests {
42 result, err := TransformDMLToSelect(context.Background(), base.TransformContext{}, t.Input, "DB", "backupDB", "rollback")
43 a.NoError(err)
44 slices.SortFunc(result, func(a, b base.BackupStatement) int {
45 if a.TargetTableName == b.TargetTableName {
46 if a.Statement < b.Statement {
47 return -1
48 }
49 if a.Statement > b.Statement {
50 return 1
51 }
52 return 0
53 }
54 if a.TargetTableName < b.TargetTableName {
55 return -1
56 }
57 if a.TargetTableName > b.TargetTableName {
58 return 1
59 }
60 return 0
61 })
62
63 if record {
64 tests[i].Result = result
65 } else {
66 a.Equal(t.Result, result, t.Input)
67 }
68 }
69 if record {
70 yamltest.Record(t, filepath, tests)
71 }
72}
73
74func TestBackupOmniBoundaryCases(t *testing.T) {
75 tests := []struct {

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