MCPcopy Create free account
hub / github.com/rilldata/rill / TestDBFilePath

Function TestDBFilePath

runtime/drivers/sqlite/backups_test.go:128–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestDBFilePath(t *testing.T) {
129 tmpDir, _ := filepath.EvalSymlinks(t.TempDir())
130 cases := []struct {
131 dsn string
132 expected string
133 }{
134 {":memory:", ""},
135 {"file:rill?mode=memory&cache=shared", ""},
136 {"file::memory:?cache=shared", ""},
137 {filepath.Join(tmpDir, "data.sqlite"), filepath.Join(tmpDir, "data.sqlite")},
138 {"file:" + filepath.Join(tmpDir, "data.sqlite"), filepath.Join(tmpDir, "data.sqlite")},
139 }
140 for idx, tc := range cases {
141 t.Run(fmt.Sprintf("case-%d", idx), func(t *testing.T) {
142 cfg := map[string]any{"dsn": tc.dsn}
143 h, err := driver{}.Open("", "", cfg, storage.MustNew(t.TempDir(), nil), activity.NewNoopClient(), zap.NewNop())
144 require.NoError(t, err)
145 defer h.Close()
146
147 dbPath, err := h.(*connection).dbFilePath(t.Context())
148 require.NoError(t, err)
149 require.Equal(t, tc.expected, dbPath)
150 })
151 }
152}
153
154func must[T any](v T, err error) T {
155 if err != nil {

Callers

nothing calls this directly

Calls 8

MustNewFunction · 0.92
NewNoopClientFunction · 0.92
dbFilePathMethod · 0.80
TempDirMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65
ContextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected