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

Function TestFailpoint_ResizeFileFail

tests/failpoint/db_failpoint_test.go:102–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestFailpoint_ResizeFileFail(t *testing.T) {
103 db := btesting.MustCreateDB(t)
104
105 err := gofail.Enable("resizeFileError", `return("resizeFile somehow failed")`)
106 require.NoError(t, err)
107
108 err = db.Fill([]byte("data"), 1, 10000,
109 func(tx int, k int) []byte { return []byte(fmt.Sprintf("%04d", k)) },
110 func(tx int, k int) []byte { return make([]byte, 100) },
111 )
112
113 require.Error(t, err)
114 require.ErrorContains(t, err, "resizeFile somehow failed")
115
116 // It should work after disabling the failpoint.
117 err = gofail.Disable("resizeFileError")
118 require.NoError(t, err)
119 db.MustClose()
120 db.MustReopen()
121
122 err = db.Fill([]byte("data"), 1, 10000,
123 func(tx int, k int) []byte { return []byte(fmt.Sprintf("%04d", k)) },
124 func(tx int, k int) []byte { return make([]byte, 100) },
125 )
126
127 require.NoError(t, err)
128}
129
130func TestFailpoint_LackOfDiskSpace(t *testing.T) {
131 db := btesting.MustCreateDB(t)

Callers

nothing calls this directly

Calls 5

MustCreateDBFunction · 0.92
FillMethod · 0.80
MustCloseMethod · 0.80
MustReopenMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected