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

Function TestRestore

backend/plugin/parser/plsql/restore_test.go:28–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestRestore(t *testing.T) {
29 tests := []restoreCase{}
30
31 const (
32 record = false
33 )
34 var (
35 filepath = "test-data/test_restore.yaml"
36 )
37
38 a := require.New(t)
39 yamlFile, err := os.Open(filepath)
40 a.NoError(err)
41
42 byteValue, err := io.ReadAll(yamlFile)
43 a.NoError(yamlFile.Close())
44 a.NoError(err)
45 a.NoError(yaml.Unmarshal(byteValue, &tests))
46
47 for i, t := range tests {
48 result, err := GenerateRestoreSQL(context.Background(), base.RestoreContext{
49 GetDatabaseMetadataFunc: fixedMockDatabaseMetadataGetter,
50 }, t.Input, &store.PriorBackupDetail_Item{
51 SourceTable: &store.PriorBackupDetail_Item_Table{
52 Database: "instances/i1/databases/" + t.OriginalDatabase,
53 Table: t.OriginalTable,
54 },
55 TargetTable: &store.PriorBackupDetail_Item_Table{
56 Database: "instances/i1/databases/" + t.BackupDatabase,
57 Table: t.BackupTable,
58 },
59 StartPosition: &store.Position{
60 Line: 0,
61 Column: 0,
62 },
63 EndPosition: &store.Position{
64 Line: math.MaxInt32,
65 Column: 0,
66 },
67 })
68 a.NoError(err)
69
70 if record {
71 tests[i].Result = result
72 } else {
73 a.Equal(t.Result, result, t.Input)
74 }
75 }
76 if record {
77 yamltest.Record(t, filepath, tests)
78 }
79}
80
81func TestRestoreOmniBoundaryCases(t *testing.T) {
82 t.Run("multi-line update", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected