MCPcopy
hub / github.com/etcd-io/bbolt / TestSurgery_Meta_Update

Function TestSurgery_Meta_Update

cmd/bbolt/command/command_surgery_meta_test.go:37–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestSurgery_Meta_Update(t *testing.T) {
38 testCases := []struct {
39 name string
40 root common.Pgid
41 freelist common.Pgid
42 pgid common.Pgid
43 }{
44 {
45 name: "root changed",
46 root: 50,
47 },
48 {
49 name: "freelist changed",
50 freelist: 40,
51 },
52 {
53 name: "pgid changed",
54 pgid: 600,
55 },
56 {
57 name: "both root and freelist changed",
58 root: 45,
59 freelist: 46,
60 },
61 {
62 name: "both pgid and freelist changed",
63 pgid: 256,
64 freelist: 47,
65 },
66 {
67 name: "all fields changed",
68 root: 43,
69 freelist: 62,
70 pgid: 256,
71 },
72 }
73
74 for _, tc := range testCases {
75 for i := 0; i <= 1; i++ {
76 tc := tc
77 metaPageId := uint32(i)
78
79 t.Run(tc.name, func(t *testing.T) {
80 pageSize := 4096
81 db := btesting.MustCreateDBWithOption(t, &bolt.Options{PageSize: pageSize})
82 srcPath := db.Path()
83
84 defer requireDBNoChange(t, dbData(t, db.Path()), db.Path())
85
86 var fields []string
87 if tc.root != 0 {
88 fields = append(fields, fmt.Sprintf("root:%d", tc.root))
89 }
90 if tc.freelist != 0 {
91 fields = append(fields, fmt.Sprintf("freelist:%d", tc.freelist))
92 }
93 if tc.pgid != 0 {
94 fields = append(fields, fmt.Sprintf("pgid:%d", tc.pgid))

Callers

nothing calls this directly

Calls 13

MustCreateDBWithOptionFunction · 0.92
NewRootCommandFunction · 0.92
ReadMetaPageAtFunction · 0.92
requireDBNoChangeFunction · 0.85
dbDataFunction · 0.85
RunMethod · 0.80
MagicMethod · 0.80
VersionMethod · 0.80
RootPageMethod · 0.80
RootBucketMethod · 0.80
FreelistMethod · 0.80
PathMethod · 0.45

Tested by

no test coverage detected